【问题标题】:Applescript to "quit current application" dialogApplescript“退出当前应用程序”对话框
【发布时间】:2014-09-09 16:53:37
【问题描述】:

我正在尝试制作一个 Applescript 以与 VoiceOver 一起运行以弹出一个对话框,要求退出当前的应用程序。我能够让一个工作,但它只在某些时候工作。我相信这是因为某些应用程序中的内存问题,这就是为什么会有延迟。我试着告诉“最前面的”应用程序退出,但它也没有工作。

    display dialog "Quit current application?" buttons {"cancel", "ok"} default button         "ok"
    if result = {button returned:"ok"} then
        delay 1.7

        tell application "System Events" to key code 12 using command down

    else if result = {button returned:"cancel"} then

    end if

【问题讨论】:

    标签: macos applescript voiceover


    【解决方案1】:

    看看下面的效果是否更好。不需要 UI 的东西,因为绝大多数应用程序都会理解或响应退出命令。我要做的第一件事是获取最前面的进程(实际上,file 路径对于某些应用程序(例如 NeoOffice)更安全,也就是说,比仅获取name 更安全)。

    tell application "Finder" to set p to item 1 of (get file of (processes whose frontmost = true)) as text
    
    display dialog ("Quit current application?" & return & "(" & p & ")") buttons {"cancel", "ok"} default button 2
    
    if button returned of (result) = "ok" then
        tell application p to quit
    end if
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-19
      • 1970-01-01
      • 2011-04-11
      • 1970-01-01
      相关资源
      最近更新 更多