如何使用AppleScript在系统打印对话框中按下Enter键?

6
我希望自动打印Chrome窗口(无对话框),如果它们符合某种URL模式(例如不属于给定的一组URL),您能否使用Apple脚本实现这一点?能否分享一个例子?(我没有苹果电脑,所以无法自己尝试)

“print chrome windows” 是什么意思? - scohe001
所以你想要一个脚本来遍历所有打开的Chrome窗口,如果它们不在指定页面列表中之一,你想要...打开标签页?打开什么标签页?将所有适用的窗口压缩成标签页? - scohe001
我只是想检查当前打开的标签页,如果它们符合某个条件,则在不弹出对话框的情况下将它们打印出来。接受的答案对我有用,只需要稍作调整即可。 - Uri
啊,抱歉,我想到的打印是输出到控制台(最近我做了太多的Python)。很高兴你得到了答案! - scohe001
1个回答

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

打印是每个应用程序中标准套件的一部分,如果您使用它,可以减少错误的机会。 - scohe001

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接