0

I use the following AppleScript (assigned to keystroke Cmd+Ctrl+5) to start screen recordings (adapted from here). If I create an Automator Quick Action and assign the keystroke to it, it takes 6s until the screen recording starts. If I call the script via osascript ./screenrecord_starter.scpt from the command line, it takes about 12s. Why does it take so long (and how can this be improved [either by how the script is called or by the script itself])?

#!/usr/bin/osascript

--  Setup screen recording (mimics 'Cmd-S-5')
tell application "System Events" to keystroke "%" using {shift down, command down}

--  Start the screen recording
tell application "System Events" to tell process "Screen Shot"
    repeat until exists its front window
        delay 0.1
    end repeat
    if not (exists button "Record" of its front window) then
        click checkbox "Record Entire Screen" of its front window
    end if
    click button "Record" of its front window
end tell

I'm working on macOS 10.15.6 (Catalina)

Update

I did some more tests and it really seems to be the AppleScript that slows things down. If I install the command-line tool cliclick and assign cliclick kd:cmd,shift t:5 m:1205,989 kp:enter to a Quick-Action-based keystroke (which mimics the clicking sequence to start screen recording; you might need to adjust the mouse position m:1205,989), then I see delays of about 1s only.

3
  • I not where I can test at the moment, however, as I'm the one that wrote the answer in the link of your OP, I do not recall there being a large delay as you've mentioned. When I get back to my computer later today I'll check things out, if no one else has answered. Commented Sep 14, 2020 at 18:05
  • ahhh, that's nice! I liked your solution very much (I really feel Apple should by default bind this to a key combination... doesn't make much sense to be able to 'stop' a recording but not to 'start' one). Looking forward to hear from your test results. There is in general some delay (3s) when starting a recording (start speaking right away and your voice will be truncated), but then it's still taking far too long IMHO.
    – mathlete
    Commented Sep 14, 2020 at 18:13
  • I tried this in Keyboard Maestro and if I have Keyboard Maestro do the keystroke (instead of having AppleScript do it) then it happens immediately. But with. the keystroke in AppleScript, it is slow, so it’s definitely that first line.
    – TJ Luoma
    Commented Sep 15, 2020 at 3:51

0

You must log in to answer this question.

Browse other questions tagged .