在按键 ESC 上从 运行 停止 applescript 脚本
stop applescript script from running on keypress ESC
我有一个将击键发送到 TextEdit 的 applescript。我需要能够通过简单地按 ESC 键随时停止脚本。我在网上尝试了一些我发现的示例,但 none 似乎有效。我不知道我在做什么哈哈。任何帮助都会很棒
这是无效示例
activate application "TextEdit"
repeat until (keys pressed) is {"esc"}
set keys_pressed to keys pressed
if keys_pressed is not {} then
tell application "System Events"
key code 18
end tell
delay (random number from 0.2 to 0.3)
tell application "System Events"
key code 19
end tell
delay (random number from 0.2 to 0.3)
end if
end repeat
对不起,我认为你不能只用 AppleScript 做到这一点,但我推荐 Cocoa-AppleScript,下载 Xcode 并制作一个 Cocoa AppleScript 应用程序,Cocoa AppleScript 允许您使用 Cocoa Windows 链接到 Applescript 代码,然后您可以制作一个菜单栏项目以停止重复
我有一个将击键发送到 TextEdit 的 applescript。我需要能够通过简单地按 ESC 键随时停止脚本。我在网上尝试了一些我发现的示例,但 none 似乎有效。我不知道我在做什么哈哈。任何帮助都会很棒
这是无效示例
activate application "TextEdit"
repeat until (keys pressed) is {"esc"}
set keys_pressed to keys pressed
if keys_pressed is not {} then
tell application "System Events"
key code 18
end tell
delay (random number from 0.2 to 0.3)
tell application "System Events"
key code 19
end tell
delay (random number from 0.2 to 0.3)
end if
end repeat
对不起,我认为你不能只用 AppleScript 做到这一点,但我推荐 Cocoa-AppleScript,下载 Xcode 并制作一个 Cocoa AppleScript 应用程序,Cocoa AppleScript 允许您使用 Cocoa Windows 链接到 Applescript 代码,然后您可以制作一个菜单栏项目以停止重复