AppleScript的延迟问题 [英] Applescript delay issue

查看:618
本文介绍了AppleScript的延迟问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试,我将在我的OSX的应用程序以后使用的AppleScript。
我得到下面的按钮,点击命令之后6秒的延迟。
经过一番研究,似乎这是一个已知的问题。
我觉得有趣的是,如果我使用的商业应用QuicKeys执行相同
点击链接没有延迟,所以我以为他们发现周围的工作。
任何人有任何想法?

 告诉应用程序系统事件
     告诉进程的Pro Tools
         最前面设置为1
         单击窗口1按钮曲目弹出
          - 下一个命令6之前秒延时发送
         关键code 36 - 返回键击
     告诉结束
 告诉结束


解决方案

有同样的问题,并通过封闭的点击造成的忽略了应用程序的响应延迟块解决它。这里是一个快速摘要:

OLD code(导致6秒延时)

 告诉应用程序系统事件告诉进程SystemUIServer
    集bt至菜单栏1(第一个菜单栏项目的描述是蓝牙)
    点击BT
    告诉(第一个菜单项,其标题为SBH80)BT的菜单
        点击
        告诉菜单1
            如果存在菜单项断开连接,然后
                点击菜单项断开
            其他
                点击菜单项连接
            万一
        告诉结束
    告诉结束
告诉结束

新的code(无延时)

 告诉应用程序系统事件告诉进程SystemUIServer    集bt至菜单栏1(第一个菜单栏项目的描述是蓝牙)
    忽略了应用程序的响应
        点击BT
    忽略结束
告诉结束做shell脚本killall系统\\\\事件
延迟0.1
告诉应用程序系统事件告诉进程SystemUIServer    告诉(第一个菜单项,其标题为SBH80)BT的菜单
        点击
        告诉菜单1
            如果存在菜单项断开连接,然后
                点击菜单项断开
            其他
                点击菜单项连接
            万一
        告诉结束
    告诉结束
告诉结束

请在下面列出的线程检查详细的解答。

<一个href=\"http://stackoverflow.com/questions/21270264/speed-up-applescript-ui-scripting?answertab=active#tab-top\">Speed达AppleScript的UI脚本?

希望这有助于。

I am testing applescripts that I will use later in my OSX app. I'm getting a 6 sec delay after the click button command below. After some research it seems that this is a known issue. What I find interesting is, if i use the commercial app QuicKeys to perform the same button click there is no delay, so I assume they found a work around. Anybody have any ideas?

 tell application "System Events"
     tell process "Pro Tools"
         set frontmost to 1
         click button "Track List pop-up" of window 1 
         --  6 seconds delay before next command is sent
         key code 36   -- return key stroke
     end tell
 end tell

解决方案

Was having the same problem and resolved it by enclosing the click causing delay in the ignoring application responses block. Here is a quick summary:

OLD CODE (Causes 6 sec delay)

tell application "System Events" to tell process "SystemUIServer"
    set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
    click bt
    tell (first menu item whose title is "SBH80") of menu of bt
        click
        tell menu 1
            if exists menu item "Disconnect" then
                click menu item "Disconnect"
            else
                click menu item "Connect"
            end if
        end tell
    end tell
end tell

NEW CODE (No delay)

tell application "System Events" to tell process "SystemUIServer"

    set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
    ignoring application responses
        click bt
    end ignoring
end tell

do shell script "killall System\\ Events"
delay 0.1
tell application "System Events" to tell process "SystemUIServer"

    tell (first menu item whose title is "SBH80") of menu of bt
        click
        tell menu 1
            if exists menu item "Disconnect" then
                click menu item "Disconnect"
            else
                click menu item "Connect"
            end if
        end tell
    end tell
end tell

Please check detailed answer in the thread listed below.

Speed up AppleScript UI scripting?

Hope this helps.

这篇关于AppleScript的延迟问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆