我在尝试使用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,所以如果我在其他地方搞砸了,请告诉我。