I want to use a Push Button Action to access the buttons that appear when preparing for a QuickTime screen recording (⇧⌘5). In the screenshot below I show these buttons, along with the pop-up menu for the “Options” button; my goal is to be able to toggle the “Remember Last Selection” submenu item shown by the red arrow.
I think the problem is that the the Push Button Action’s ability to scan the buttons of an application can only happen if it is behind KM. However, those QT buttons are always “in the front”.
The button's name is Options, but Click a Button doesn't seem able to click it, based on a simple test. (Perhaps because it's a floating overlay that prevents any other app from sending it keystrokes? I"m not sure.)
But because the screenshot overlay always appears at the same location onscreen, why not just...
Click at the known on-screen location of the Options button
Type Rem to select the "Remember" menu option
Pause some very short amount of time to make sure it's selected
Send the Return key
Yes, clicking buttons by name is generally better, but in this case, I don't think you'll be able to activate the menu that way.
They also may not be part of QuickTime Player but of the background screencaptureui process.
After a quick fiddle, this should work to toggle that menu item:
tell application "System Events"
tell application process "screencaptureui"
tell window 1
tell button "Options"
click
repeat while not (exists menu 1)
delay 0.1
end repeat
tell menu item "Remember Last Selection" of menu 1 to click
end tell
end tell
end tell
end tell
Pop it into an AppleScript Action at the appropriate place in your macro.
@Nige_S When I tried the following macro including your script it did not click the Options button and gave the error shown – but then, maybe I need to include some other actions? The actions above it have worked in other macros and you can see at the bottom that it is bringing up the right menu
@griffman Your idea to click at absolute points on the screen works, and I’m working on the logic to get it to do what I want to. Of course, you know better than I do the disadvantages of absolute clicks like that, but at least I have a way that can work now.
Well, Apple have made a real mess of that! Not only is there extra nesting of elements (expected in the new Swift UI world), they've some managed to create a menu that isn't associated with a process... You'll have to go old-school and select the menu item by simulated typing-and-Return.
Try this script instead:
tell application "System Events"
tell application process "screencaptureui"
tell window 1
tell group 1
tell menu button 1
click
delay 0.1
end tell
keystroke "Remember"
keystroke return
end tell
end tell
end tell
end tell
@Nige_S That solved it. It’s great because you can see the Option menu open and then clicking the Remember Last Selection item – I’d attach a screen recording but apparently you can’t make a screen recording of these steps, although you can take a screenshot while it’s working as shown below:
Having this action makes automating screen recording possible, including the crucial part: specifying what part of the screen is to be recorded – thanks.
You can record from the command line, and therefore with via a KM "Execute Shell Script" Action, using the screencapture command with the options required. Less disruptive and more controllable than bringing up the UI to do it.
I want to be able to make instructional videos for example how to use SketchUp or some particular woodworking project, etc. and it gets a little tiresome to constantly get everything set up each time. But since I always use the same size window, the same resolution, the same volume, etc. I wanted to make a keyboard maestro macro to do all that for me.
I'm trying to slowly educate myself in how keyboard maestro does things. I have no problem at all using the command line, for example, I use ffmpeg all the time for video and audio editing. So, if you could point me to where I could find out how to screen or audio record via the command line I'd be happy to learn.
That would record a 10-second movie (the -V 10 flag) at screen location 100,200 in a block measuring 400x500 pixels (-R 100,etc), and show the mouse clicks (-k). Use -v to record an untimed video, and press any key to stop the recording.