如何使用applescript在系统打印对话框中输入?

时间:2013-08-13 14:47:45

标签: google-chrome printing applescript osx-snow-leopard

我想自动打印镀铬窗口(没有对话框),如果它们符合某种URL模式(例如,不是一组给定的URL)。

你可以使用苹果脚本吗?有人可以分享一个例子吗? (我没有Mac,所以我无法真正尝试自己)

1 个答案:

答案 0 :(得分:6)

set i to 1
tell application "Google Chrome"
    activate
    tell window 1
        repeat with t in tabs
            --if title of t starts with "Example" then
            if {"http://example.com/", "http://aa.com/"} does not contain URL of t then
                set active tab index to i
                tell t to print
                delay 1
                tell application "System Events"
                    click button "Print" of window 1 of process "Chrome"
                    --keystroke return
                end tell
            end if
            set i to i + 1
        end repeat
    end tell
end tell