NLe*_*Led 1 macos applescript automator toggle
我试图通过AppleScript检查应用程序是否打开
这是以下代码:
on run {input, parameters}
quit application "KeyboardViewer"
return input
end run
Run Code Online (Sandbox Code Playgroud)
但是我希望它首先检查KeyboardViewer是否打开,如果是,则退出应用程序,如果没有,则启动它.在某种程度上,代码应该切换应用程序.
我不熟悉AppleScript的编码(这里的第一个计时器)所以我很感激一些见解.
谢谢
编辑
我一直在尝试使用它,这似乎有效,是否有更有效的方法?我想看看你的意见
on run {input, parameters}
if application "KeyboardViewer" is running then
quit application "KeyboardViewer"
else
activate application "KeyboardViewer"
end if
return input
end run
Run Code Online (Sandbox Code Playgroud)
使用此脚本时有一个小的(少于1秒)延迟.有没有办法让它更快?
这似乎有效:
on run {input, parameters}
if application "KeyboardViewer" is running then
quit application "KeyboardViewer"
else
activate application "KeyboardViewer"
end if
return input
end run
Run Code Online (Sandbox Code Playgroud)
我学到的是if application "APPLICATION NAME" is running检查应用程序是否打开.
| 归档时间: |
|
| 查看次数: |
4199 次 |
| 最近记录: |