【发布时间】:2017-06-02 19:56:37
【问题描述】:
我无法弄清楚如何检测 AppleScript 中按下的键以及如何延迟直到该键被释放。我想为缩放做一个切换,我拥有其他一切(我认为)。这是我当前的代码
on idle
set ztoggle to 0
repeat
--how do i make it so a key is needed to run this loop? maybe an 'if (im not sure what to put here) then' loop?--
if (ztoggle = 1) then
set ztoggle to 0
else if (ztoggle = 0) then
set ztoggle to 1
end if
--how do i make it so the program waits at this line until the key from before is released? i was thinking delay, but im not sure--
if (ztoggle = 1) then
tell application "System Events"
key code 28 using {option down, command down}
end tell
end if
set ztoggle to 0
end repeat
end idle
有人知道我会怎么做吗?另外,这是我第一次尝试使用 AppleScript,所以如果我在其他地方搞砸了,请告诉我。
【问题讨论】:
标签: applescript keypress