【问题标题】:How to use applescript to hit enter on system printing dialog box?如何使用applescript在系统打印对话框中敲回车?
【发布时间】:2013-08-15 06:11:57
【问题描述】:

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

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

【问题讨论】:

  • “打印 chrome windows”是什么意思?
  • 因此您希望脚本通过所有打开的 chrome 窗口,如果它们不在您想要的指定页面列表之一上...打开选项卡?打开什么标签?将所有适用于选项卡的窗口压缩?
  • 我只是想检查当前打开的选项卡,如果它们回答了某个条件,则打印它们而不显示对话框。接受的答案对我有用,需要稍作调整。
  • 啊抱歉,通过打印我想输出到控制台(我最近做了太多 python)。很高兴你得到了答案!

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


【解决方案1】:
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

【讨论】:

  • 打印是每个应用程序标准套件的一部分,如果您使用它会减少出错的机会
猜你喜欢
  • 1970-01-01
  • 2012-03-17
  • 2014-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多