如何使用appescription在系统打印对话框中点击回车键



如果chrome窗口符合某种URL模式(例如,不属于给定的URL集),我想自动打印它们(没有对话框)。

你能用苹果脚本吗?有人能举个例子吗?(我没有mac,所以我不能自己做实验)

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