【问题标题】:How to quit Xcode with confirmation dialog box using apple script如何使用苹果脚本通过确认对话框退出 Xcode
【发布时间】:2016-10-04 23:12:21
【问题描述】:

我正在尝试编写一个脚本来退出当前正在构建的应用程序的 Xcode。我当前的脚本仅涵盖退出 Xcode,但我无法处理 Xcode 上弹出的确认对话框。在确认框中,有两个按钮选项:取消或停止任务。我想点击停止任务按钮。请帮忙。

这是我目前的 AppleScript:

set apps to {"Simulator","Xcode"}
repeat with thisApp in apps
   tell application thisApp to quit
end repeat
tell application "System Events"
   tell process "Xcode"
    click button "Stop Tasks" of sheet 1 of window 1
   end tell
end tell

这是我当前不起作用的applescript。

【问题讨论】:

    标签: xcode applescript


    【解决方案1】:

    我能够通过确认对话框提示来解决我关于终止 Xcode 的问题。这是我想出的applescript:

    try
        with timeout of 10 seconds
            quit application "Simulator"
            quit application "Xcode"
        end timeout
    on error number e
        if e is -1712 then
            activate application "Xcode"
            tell application "System Events"
                tell application process "Xcode"
                    keystroke return
                end tell
            end tell
        end if
    end try
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      相关资源
      最近更新 更多