我正在尝试减少步骤的数量并提高我的AppleScript的性能,我只是想知道是否有一些我可以使用的常用功能。
这是一个示例脚本......
tell application "QuickTime Player"
activate
-- Get the iCloud file path to avoid permission error
set filePath to "Macintosh HD:Users:jm:Library:Mobile Documents:com~apple~QuickTimePlayerX:Documents:movie.wav"
set f to a reference to file filePath
-- Get a handle to the initial window
set windowID to id of first window whose name = "Audio Recording"
set audio to first document whose name = (get name of first window whose id = windowID)
tell audio
stop
end tell
-- Get second handle to new titled window
set windowID2 to id of first window whose name = "Untitled"
set audio2 to first document whose name = (get name of first window whose id = windowID2)
tell audio2
-- Save audio file
save audio2 in f
end tell
-- Get third handle to new titled window
set windowID3 to id of first window whose name = "movie.wav.qtpxcomposition"
set audio3 to first document whose name = (get name of first window whose id = windowID3)
tell audio3
close audio3 saving no
end tell
end tell
这是第二个脚本,在开始录制的脚本之后调用。
为什么你的语句首先通过名称检索窗口的id,然后是通过id检索同一窗口名称的语句?这看起来有点多余。
—
CJK