2014-03-27 32 views
4

我有這個簡單的代碼:Quicktime播放器錄製與小牛隊的AppleScript打破?

tell application "QuickTime Player" 
activate 
new screen recording 
document "Screen Recording" start 
delay 10 
document "Screen Recording" stop 
end tell 

這記錄了10秒的動畫我10.8的機器上沒有問題。 但在10.9 mac-mini上,QT掛在上面的停止操作上。 它掛在窗口上並顯示消息「Finishing Recording」。 我必須強制退出它,而且仍然是同樣的事情。如果我手動執行這些步驟,它們就可以工作。但是使用AppleScript或甚至與Automator相同的步驟也有同樣的問題。

我升級到10.9.2,但仍然是同樣的問題。

這是一個已知的錯誤嗎?任何建議工作?

謝謝。

+0

僅供參考:我爲自己檢查了腳本,並在10.9上找到了相同的懸掛問題。所以你的問題是有效的。不幸的是我沒有解決方案。 – regulus6633

+0

感謝regulus6633檢查你的結局。這似乎是一個非常奇怪的錯誤。 – user43823

回答

2

我遇到了同樣的問題,發現問題不在stop,但在非交互式start,所以我試着開始記錄(僞)交互式,它的工作完美。

tell application "QuickTime Player" 
    activate 
    new screen recording 
    activate 
    tell application "System Events" to tell process "QuickTime Player" 
     key code 49 
    end tell 
    document "Screen Recording" start 
    delay 10 
    document "Screen Recording" stop 
end tell 

它仍然呼籲start,而不是模仿一下,因爲我還沒有找到一種方法,使其工作。需要

0

兩個技巧:

  1. 發送空格鍵的QuickTime播放器開始前,以避免Finishing...對話框被卡住。 (信貸給@outring)
  2. 我們需要模擬一個鼠標點擊。這並不容易,我們需要通過CoreGraphics(又名Quartz)來完成。我們可以用Objective-C(需要編譯),Python(通過PyObjc橋)或Swift編寫。
  3. 不知何故,在鼠標點擊後約2秒鐘開始錄製,因此我們需要爲10秒鐘的錄像休眠12秒。

的工作腳本看起來就像這樣:

tell application "QuickTime Player" 
    activate 
    new screen recording 
    tell application "System Events" to tell process "QuickTime Player" to key code 49 
    document "Screen Recording" start 
    do shell script "python -c 'import Quartz; mouse_location = Quartz.NSEvent.mouseLocation(); [ Quartz.CGEventPost(Quartz.kCGHIDEventTap, Quartz.CGEventCreateMouseEvent(None, mouse_action, mouse_location, Quartz.kCGMouseButtonLeft)) for mouse_action in [ Quartz.kCGEventLeftMouseDown, Quartz.kCGEventLeftMouseUp ] ]'" 
    delay 12 
    document "Screen Recording" stop 
end tell 
3

我做這樣的事情,記錄從CI屏幕,它總是對我的作品:

set filePath to (path to desktop as string) & "ScreenRecordingFile.mov" 
 

 
tell application "System Events" to tell process "Simulator" 
 
\t set frontmost to true 
 
end tell 
 

 
tell application "QuickTime Player" 
 
\t activate 
 
\t set newScreenRecording to new screen recording 
 
\t delay 1 
 
\t tell application "System Events" 
 
\t \t tell process "QuickTime Player" 
 
\t \t \t set frontmost to true 
 
\t \t \t key code 49 
 
\t \t end tell 
 
\t end tell 
 
\t tell newScreenRecording 
 
\t \t start 
 
\t \t delay 15 
 
\t \t stop 
 
\t end tell 
 
\t export document 1 in (file filePath) using settings preset "720p" 
 
\t close document 1 saving no 
 
end tell

相關問題