macosapplescript

AppleScript - open Screenshot app and start recording screen (Mac mini M4)


I need to record the screen using the Screenshot application. This script launches the Screenshot app, but it does not start recording:

tell application "Screenshot"
    activate
end tell
delay 3
tell application "System Events"
    keystroke return
end tell

Solution

  • Use open -a Screenshot to run Screenshot as a background process:

    tell application "System Events"
        do shell script "open -a Screenshot"
        delay 1
        tell process "Screenshot"
            click checkbox "Record Entire Screen" of window 1
            delay 0.5 
            click button "Record" of window 1
        end tell
    end tell
    

    To stop recording after 10 seconds, put following before last end tell:

    delay 10
    key code 53 using {command down, control down}