Skip to content

Instantly share code, notes, and snippets.

@pwc3
Last active May 27, 2019 05:17
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pwc3/e611504878fd3e18ce91 to your computer and use it in GitHub Desktop.
Save pwc3/e611504878fd3e18ce91 to your computer and use it in GitHub Desktop.
set theProcessName to "iOS Simulator"
set theWindowNumber to 1
tell application "System Events"
tell process theProcessName
activate
tell window theWindowNumber
set thePosition to position
set theSize to size
end tell
end tell
end tell
tell application "QuickTime Player"
activate
new screen recording
delay 1
tell application "System Events" to key code 49
delay 1
do shell script "~/bin/clickdrag -x " & (item 1 of thePosition) & " -y " & (item 2 of thePosition) & " -dx " & (item 1 of theSize) & " -dy " & (item 2 of theSize)
end tell
@AlexChambers
Copy link

Thanks for this @pwc3

I've made two changes to get this working for me today (April 2018):

  1. Change "iOS Simulator" to "Simulator". (Of course, you can still select any app of your choosing.)
  2. Append .swift to the clickdrag filename: ~/bin/clickdrag.swift.

Here's my Start Screen Recording.scpt file:

set theProcessName to "Simulator"
set theWindowNumber to 1

tell application "System Events"
	tell process theProcessName
		activate
		tell window theWindowNumber
			set thePosition to position
			set theSize to size
		end tell
	end tell
end tell

tell application "QuickTime Player"
	activate
	new screen recording
	delay 1
	tell application "System Events" to key code 49
	delay 1
	do shell script "~/bin/clickdrag.swift -x " & (item 1 of thePosition) & " -y " & (item 2 of thePosition) & " -dx " & (item 1 of theSize) & " -dy " & (item 2 of theSize)
end tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment