Recording Quicktime Player using Applescript on Mavericks?

I have this simple code:

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

Records a 10 second movie on my 10.8 computer without any problems. But at 10.9 the mac-mini QT freezes when the stop above is in effect. He hangs at the window with the message "End recording." I have to make him go out and everything is the same. If I do these steps manually, they will work. But with AppleScript or even with the same steps with Automator they have the same problem.

I updated to 10.9.2, but still the same problem.

Is this a known bug? Any job offers?

Thank.

+4
source share
3 answers

I am doing something similar for recording a screen from CI, and it always works for me:

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

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

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

, 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 , .

+2

:

  • QuickTime Player , Finishing.... ( @outring)
  • . , CoreGraphics (aka Quartz). Objective-C ( ), Python ( PyObjc), Swift.
  • - 2 , 12 10- .

script :

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
0
source

Source: https://habr.com/ru/post/1533644/


All Articles