我想創建一個applescript來捕獲一個窗口。鍵盤快捷鍵是cmd + shift + 4然後是空格。我不能在applescript中使用它。Applescript捕獲窗口
我的代碼:
tell application "system events"
keystroke "21, 49" using {command down, shift down}
end tell
它不工作。使用空格鍵對其進行腳本編寫的問題。我需要保持CMD,轉變 & 然後按空間吧。
我想創建一個applescript來捕獲一個窗口。鍵盤快捷鍵是cmd + shift + 4然後是空格。我不能在applescript中使用它。Applescript捕獲窗口
我的代碼:
tell application "system events"
keystroke "21, 49" using {command down, shift down}
end tell
它不工作。使用空格鍵對其進行腳本編寫的問題。我需要保持CMD,轉變 & 然後按空間吧。
嘗試:
tell application "System Events"
keystroke (ASCII character 36) using {command down}
delay 1
keystroke space
end tell
這AppleScript的可能更好地爲你,而不是使用GUI腳本 它採用了屏幕捕獲命令行。更多信息看screencapture Man page
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 & "\""
如果你想要的是去那一點,然後用這個:
告訴應用程序「系統事件」
鍵碼21使用{下移,命令下來}
延遲0.1
關鍵代碼49
結束告訴