【问题标题】:Control Quicktime Using Applescript使用 Applescript 控制 Quicktime
【发布时间】:2020-04-03 10:54:39
【问题描述】:

我正在寻找使用 Applescript 控制 Quicktime 的解决方案。 我需要做的就是—— - 打开 quicktime 并开始录制 - 停止录制并将文件保存到设定的位置。

从以前的帖子中,我设法得到了以下信息。

    set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " & "myfile" & ".mov"

tell application "QuickTime Player"
    set newMovieRecording to new movie recording
    tell newMovieRecording
        start
        delay 5
        pause
        save newMovieRecording in POSIX file theFilePath
        stop
        close newMovieRecording
    end 

这非常有效,但是对于这个项目,我需要单独的脚本提示来开始和停止录制,而不是等待/延迟。

开始我使用的录音。

set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " & "myfile" & ".mov"

tell application "QuickTime Player"
    set newMovieRecording to new movie recording
    tell newMovieRecording
        start

    end tell
end tell

这很好,但是当我尝试使用下面的方法停止录制时,我会收到不理解暂停的错误

set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " & "myfile" & ".mov"

tell application "QuickTime Player"
    set MovieRecording to new movie recording
    tell MovieRecording

        pause
        save MovieRecording in POSIX file theFilePath
        stop
        close MovieRecording
    end tell
end tell

我猜这是因为当前录制的文件不再是“新电影录制”

任何想法很快如何解决??

【问题讨论】:

标签: applescript quicktime


【解决方案1】:

我使用以下示例 AppleScript 代码 来测试在QuickTime 中开始新电影录制播放器使用第一个脚本,然后用第二个脚本处理它以暂停、保存、停止关闭它。

  • 请注意,这假设 QuickTime Player 仅在一个 New Movie Recording 且未打开其他 QuickTime Player 窗口的情况下运行。

脚本 1:

tell application "QuickTime Player" to start (new movie recording)

脚本 2:

set theFilePath to POSIX path of (path to movies folder) & "myMovie.mov"

tell application "QuickTime Player"
    tell document "Movie Recording"
        pause
        save it in POSIX file theFilePath
        stop
        close
    end tell
end tell

在这两个 脚本 之间,它成功地在 Movies 文件夹中创建了 myMovie.mov 文件 我的Home 文件夹

测试是在 ma​​cOS High Sierra 下完成的。


注意:示例 AppleScript 代码就是这样,不包含任何错误处理可能是适当的。用户有责任根据需要或需要添加任何错误处理。查看AppleScript Language Guide 中的try statementerror statement。另请参阅Working with Errors。此外,在适当的情况下,可能需要在事件之间使用delay 命令,例如delay 0.5延迟设置得当。

【讨论】:

    猜你喜欢
    • 2014-05-05
    • 2022-08-05
    • 1970-01-01
    • 2023-03-28
    • 2012-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    相关资源
    最近更新 更多