1

So I've been using a script before I updated to Catalina that worked fine for screen recording. It's based on another user's SE question, but ever since the update, it looks like there is a new step.

Basically, you tell "QuickTime Player" to start (new screen recording).

But instead of a screen recording starting, it just opens a new menu which lets you select some settings, or click the screen to record using the last used settings.

I've tried using System Events to click to screen, even after a 1s delay, but it's not working.

Anyone know how to either: 1) Bypass the new menu and just start recording right away 2) Start recording once the menu has popped up (System Events doesn't detect window 1, so I'm not even sure how to navigate the UI) 3) Click the screen/UI using System Events

* Update to question *

I've edited my AppleScript code since user3439894 wrote a response. It seems to work for what I've asked. The only problem now is that I'm not sure how to save to file to a specific path. Below, I've added some code snippets of what I currently have since making edits (it just saves the screen recording to the Desktop based on the date for the time. Below that, I have my original code which saves it on the Desktop as test.mov.

My code now, after edits

1) Starting recording

tell application "QuickTime Player" to activate
tell application "QuickTime Player" to start (new 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

2) end recording

tell application "System Events" to click menu bar item 1 of menu bar 1 of application process "screencaptureui"

My Code Before Edits

3) Old way I used to start my recording before Catalina for screen recording (still works for webcam (aka Movie) recording)

tell application "QuickTime Player" to activate
tell application "QuickTime Player" to start (new screen recording)

4) Old way I used to stop and save my screen recording that doesn't work in Catalina

set filePath to "Users:mini:Desktop:test.mov"
set f to a reference to file filePath
tell application "QuickTime Player"
  pause document "screen recording"
  save document "screen recording" in f using settings preset "1080p"
  stop document "screen recording"
  close document "screen recording"
end tell
  • 4
    Please add the AppleScript code you're using to the question. – user3439894 Nov 1 '19 at 13:57
2

Without seeing your AppleScript code, all I can say is that for me, as an example, on macOS High Sierra doing a screen recording requires different coding then on macOS Catalina, as the latter no longer actually uses QuickTime Player to do the actual screen recording.

This may also hold true for macOS Mojave, however, the following example AppleScript code was only tested under macOS Catalina:

--  # Setup to do a screen recording.

tell application "QuickTime Player" to new screen recording

--  # Start the screen recording.

tell application "System Events" to tell process "Screen Shot"
    repeat until exists button "Record" of its front window
        delay 0.1
    end repeat
    click button "Record" of its front window
end tell

--  # Set the time in seconds you want the recording to be.

delay 2

--  # Stop the recording.

tell application "System Events" to ¬
    click menu bar item 1 ¬
        of menu bar 1 ¬
        of application process "screencaptureui"

At this point, by default, when the screen recording is stopped, it is saved to the Desktop as e.g. Screen Recording 2019-11-01 at 3.38.00 PM.mov on my system and opened in QuickTime Player.

Additional coding can be included to do whatever else one would like to do with the screen recording (within the limits of the target app and AppleScript).

That all said, since macOS Catalina is actually using a different application to do the actual screen recording and not QuickTime Player, one could skip the use of QuickTime Player and create the screen recording using the following example AppleScript code, which uses the system default keyboard shortcut ⇧⌘5:

--  # Setup to do a screen recording.

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

--  # Set the time in seconds you want the recording to be.

delay 2

--  # Stop the recording.

tell application "System Events" to ¬
    click menu bar item 1 ¬
        of menu bar 1 ¬
        of application process "screencaptureui"
  • Note the use of % instead of 5 in keystroke "%" as the shift key is pressed and I'm on a US English keyboard.
  • The usual caveats, regarding System Preferences > Security & Privacy > Privacy, apply.

Note: The example AppleScript code is just that and does not contain any additionally error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

| improve this answer | |
  • This answers my question perfectly, but now that I've implemented your solution, how do I save to a specific path? In QuickTime, when I am done recording, I run save document "screen recording" in f where I defined f earlier as the file path. But it seems like I will need to set the path before the recording begins. Any ideas? – Kjell Nov 2 '19 at 3:49
  • @Kjell, As I said in a comment to your OP "Please add the AppleScript code you're using to the question.", and it got 3 upvotes, which should show you the importance of being thorough when asking a question. You not adding your code is why I had to leave it with "Additional coding can be included to do whatever else one would like to do with the screen recording (within the limits of the target app and AppleScript)." I also included two different routes to take and you've not stated which you've implemented. What I posted was meant to get you on a track that can work. – user3439894 Nov 2 '19 at 4:28
  • @Kjell, There are also additional caveats not mentioned in the existing answer that have to deal with both default settings and additional settings in the "Screen Shot" process that can affect the direction of additional coding depending on what the default settings have been changed to, if at all, and in conjunction with which of the two methods was chosen. – user3439894 Nov 2 '19 at 4:28
  • Thanks for the reply. I should've added my code, but can't at the moment since I'm not at my computer and won't be until tonight or tomorrow. Both of your methods worked. I tried the shortcut keys first, which worked initially, but didn't work while recording a full screen app (game). The QuickTime method did work however. Initially didn't post code because I'm running osascript via a nodejs process, and running it as a long winding string with variables in it, so didn't want to go on tangents that weren't related to specifically the AppleScript side of things. Will get backto you – Kjell Nov 2 '19 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .