gpt4 book ai didi

macOS 定期向事件应用程序发送击键

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

我正在尝试每分钟向名为“Dbeaver”的 macOS(Mojave)应用程序发送一个击键(command+ shift+ r)只要 DBeaver 是活跃的应用程序。我已经尝试了以下没有效果。

tell application "System Events"
set activeApp to name of first application process whose frontmost is true
if "DBeaver" is in activeApp then
tell application "System Events" to keystroke "r" using {command down, shift down}

end if
end tell

如果脚本如下简单,则该脚本可以正常工作:
activate application "DBeaver" 
tell application "System Events" to keystroke "r" using {command down, shift down}

最佳答案

我没有您提到的应用程序,但我使用 TextEdit.app 按照 AppleScript 代码对此进行了测试,并且它工作正常。如果您遇到任何错误或问题,请告诉我

tell application "System Events"
repeat while (exists of application process "DBeaver")
set activeApp to name of first application process whose frontmost is true
if "DBeaver" is in activeApp then
tell its application process "DBeaver"
repeat while frontmost
keystroke "r" using {command down, shift down}
delay 60
end repeat
end tell
end if
end repeat
end tell

关于macOS 定期向事件应用程序发送击键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60268384/

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