Applescript 应用脚本捕获窗口

Applescript 应用脚本捕获窗口,applescript,Applescript,我正在尝试创建一个applescript来捕获窗口。键盘快捷键是cmd+shift+4,然后是空格。我无法在applescript中使用此选项 我的代码: tell application "system events" keystroke "21, 49" using {command down, shift down} end tell 它不起作用。使用空格键进行抄写的问题。我需要按住cmd、shift和4键,然后按空格键。尝试: tell application "System Even

我正在尝试创建一个applescript来捕获窗口。键盘快捷键是cmd+shift+4,然后是空格。我无法在applescript中使用此选项

我的代码:

tell application "system events"
keystroke "21, 49" using {command down, shift down}
end tell
它不起作用。使用空格键进行抄写的问题。我需要按住cmd、shift和4键,然后按空格键。

尝试:

tell application "System Events"
    keystroke (ASCII character 36) using {command down}
    delay 1
    keystroke space
end tell
尝试:


此Applescript可能比使用GUI脚本更适合您 它使用屏幕捕获命令行。有关更多信息,请查看


此Applescript可能比使用GUI脚本更适合您 它使用屏幕捕获命令行。有关更多信息,请查看


如果您只想达到这一点,请使用以下命令:
告诉应用程序“系统事件”
使用{shift down,command down}键代码21
延迟0.1
钥匙代码49

end tell

如果您只想到达该点,请使用以下命令:
告诉应用程序“系统事件”
使用{shift down,command down}键代码21
延迟0.1
钥匙代码49
结束语

set fileName to do shell script "date \"+Screen Shot  %Y-%m-%d at %H.%M.%S.png\""
tell application "System Events" to set thePath to POSIX path of desktop folder
do shell script "screencapture  -W " & "\"" & thePath & "/" & fileName & "\""