gpt4 book ai didi

Applescript 延迟问题

转载 作者:行者123 更新时间:2023-12-03 10:03:09 25 4
gpt4 key购买 nike

我正在测试稍后将在我的 OSX 应用程序中使用的苹果脚本。
在下面的单击按钮命令之后,我得到了 6 秒的延迟。
经过一些研究,这似乎是一个已知问题。
我觉得有趣的是,如果我使用商业应用程序 QuickKeys 来执行相同的操作
单击按钮没有延迟,所以我认为他们找到了解决方法。
有人有任何想法吗?

 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

最佳答案

遇到了同样的问题并通过在 ignoring application responses 中包含导致延迟的点击来解决它堵塞。这是一个快速总结:

旧代码(导致 6 秒延迟)

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

新代码(无延迟)
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

请在下面列出的线程中查看详细答案。

Speed up AppleScript UI scripting?

希望这可以帮助。

关于Applescript 延迟问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16126027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com