Skip to content

Instantly share code, notes, and snippets.

@Adam-Langley
Forked from pwc3/Start Screen Recording.scpt
Last active February 15, 2018 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adam-Langley/e41178e9fb6910d240e9c41bafa528b2 to your computer and use it in GitHub Desktop.
Save Adam-Langley/e41178e9fb6910d240e9c41bafa528b2 to your computer and use it in GitHub Desktop.
Utilises the enhanced 'clickdrag.swift' that allows all inputs to be negative. Also supports capturing bezel drop-shadow.
set theProcessName to "Simulator"
set theWindowNumber to 1
-- set this to 'true' to increase the captured screen region
-- to include device bezel drop-shadow
set includeDropshadowRegion to false
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
on roundedabs(num)
if num < 0 then return round (num * -1)
return round (num)
end roundedabs
tell application "QuickTime Player"
activate
new screen recording
delay 1
tell application "System Events" to key code 49
delay 1
set x to item 1 of thePosition
set y to item 2 of thePosition
set dx to item 1 of theSize
set dy to item 2 of theSize
if includeDropshadowRegion then
-- compensate for dropshadow by scaling the
-- recorded region by known percentages
set x to x - dx * 0.1
set y to y - dy * 0.038
set dx to dx * (1 + 0.2)
set dy to dy * (1 + 0.038 + 0.065)
end if
do shell script "/Applications/clickdrag.swift -x " & my roundedabs(x) & " -y " & my roundedabs(y) & " -dx " & my roundedabs(dx) & " -dy " & my roundedabs(dy) & " -negx " & (x < 0) & " -negy " & (y < 0) & " -negdx " & (dx < 0) & " -negdy " & (dy < 0)
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment