有没有办法暂停录音并使用quicktime和applescript恢复?

有没有办法暂停录音并使用quicktime和applescript恢复?,applescript,audio-recording,quicktime,Applescript,Audio Recording,Quicktime,我在AppleScript中尝试了这个: tell application "QuickTime Player" activate set doku to new audio recording start doku delay 4 pause doku end tell 当它启动QuickTime播放器并开始录制时,它不会暂停,有没有办法暂停→ 玩→ 使用AppleScript和QuickTime播放器暂停等以录制音频?好的,我对此进行了深入研究,并得

我在AppleScript中尝试了这个:

tell application "QuickTime Player"
    activate
    set doku to new audio recording
    start doku
    delay 4
    pause doku
end tell

当它启动QuickTime播放器并开始录制时,它不会暂停,有没有办法暂停→ 玩→ 使用AppleScript和QuickTime播放器暂停等以录制音频?

好的,我对此进行了深入研究,并得出了以下脚本。如果音频录制窗口打开,则此脚本将在录制暂停时开始或恢复录制,如果录制未暂停,则暂停录制。这使用python来模拟option按键(按住option键会将“停止”按钮变成“暂停”按钮),因此您可能需要安装python的Objective-C软件包。有关详细信息,请参阅:我刚刚发现默认情况下OSX上安装了PyObjc 2.5,这就足够了

tell application "QuickTime Player" to activate

tell application "System Events"
    tell process "QuickTime Player"
        tell window "Audio Recording"
            set actionButton to first button whose description is "stop recording" or description is "start recording" or description is "resume recording"

            if description of actionButton is in {"start recording", "resume recording"} then
                -- start/resume audio recording
                click actionButton
            else if description of actionButton is "stop recording" then
                -- pause audio recording
                my controlKeyEvent(true)
                click actionButton
                my controlKeyEvent(false)
            end if
        end tell
    end tell
end tell

on controlKeyEvent(isKeyDown)
    if isKeyDown then
        set boolVal to "True"
    else
        set boolVal to "False"
    end if
    do shell script "

/usr/bin/python <<END

from Quartz.CoreGraphics import CGEventCreateKeyboardEvent
from Quartz.CoreGraphics import CGEventCreate
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGHIDEventTap
import time

def keyEvent(keyCode, isKeyDown):
    theEvent = CGEventCreateKeyboardEvent(None, keyCode, isKeyDown)
    CGEventPost(kCGHIDEventTap, theEvent)

keyEvent(58," & boolVal & ");

END"
end controlKeyEvent
告诉应用程序“QuickTime Player”激活
告诉应用程序“系统事件”
告诉流程“QuickTime播放器”
告诉窗口“录音”
将actionButton设置为描述为“停止录制”或描述为“开始录制”或描述为“恢复录制”的第一个按钮
如果actionButton的描述在{“开始录制”、“恢复录制”}中,则
--开始/恢复音频录制
单击操作按钮
否则,如果操作按钮的描述为“停止录制”,则
--暂停录音
my controlKeyEvent(真)
单击操作按钮
my controlKeyEvent(错误)
如果结束
结束语
结束语
结束语
关于controlKeyEvent(isKeyDown)
如果我按下了键,那么
将布尔瓦尔设置为“真”
其他的
将布尔瓦尔设置为“False”
如果结束
执行shell脚本“

/usr/bin/python它看起来不像quicktime是用来暂停录制的;你甚至不能从主界面上暂停录制,更不用说从AppleScript了。同样,你也不能停止录制并从主界面重新启动它。录制一停止,界面就切换到“播放”模式,而且没有回头路了。我想你可能已经停止了进行单独录制,然后稍后合并。