Help... new here to Keyboard Maestro but I know it will do great things. I'm building a macro to help me undock my MacBook Pro: it ejects all disks, turns on wi-fi, and I'd like to mirror displays so that no applications are orphaned on my external monitor when I disconnect it and go to just the MacBook Pro display.
For the life of me I cannot successfully enter the Cmd-F1 keystroke into KM, or get various AppleScripts to work, or a macro to navigate to the checkbox inside System Preferences/Displays/Arrangement. I'm probably missing something simple... would appreciate your help with the most reliable method!
That's my issue, I click the down arrow, navigate to F1, hold Command (either on the laptop's keyboard or my USB keyboard) and click F1 on the dropdown, and my box fills with only F1, not Cmd-F1 — while causing my system to perform the Mirror Display action to my setup at that moment when I’m entering it. Could it be confused because I have a USB keyboard attached as well?
Thanks Peter, it seems it was necessary to press Command before clicking the menu, in my case. That process now got the Cmd-F1 into the box and it looks just like yours - however when I run the macro (or even just the Try Action under the gear icon) while using the external display, it doesn't actually execute the Cmd-F1 that mirrors the displays. It goes on to do the rest of my macro. It seems that Cmd-F1 executed by Keyboard Maestro doesn't do anything. Does anyone see this working from KM using a multi-display setup? I'm on KM 8.2.1 Trial if that matters.
JMichaelTX, for whatever reason, when I try to type directly in the box, it executes the command on my monitors right then, and only leaves F1 in the box. So something must be different between your setup and mine.
Anyway, now that I got the Cmd-F1 into the box and it looks just like yours - however when I run the macro (or even just the Try Action under the gear icon) while using the external display, it doesn't actually execute the Cmd-F1 that mirrors the displays. It goes on to do the rest of my macro. It seems that Cmd-F1 executed by Keyboard Maestro doesn't do anything. Does anyone see this working from KM using a multi-display setup? I'm on KM 8.2.1 Trial if that matters.
I have disconnected the USB keyboard dongle and it still doesn't work...
OK, I switched that to checked, but now the Keyboard Maestro step of simulating the ⌘F1 just results in a system error sound. And now the regular function keys on the laptop (adjust brightness, volume etc.) require holding the Fn key which is less convenient. (As an aside, it's curious that the USB keyboard's F1-F12 keys still do the normal system functions even when the setting is checked. Guess they send the keystroke equivalents and do not honor the setting in System Preferences.)
I'm coming to the conclusion that either KM cannot simulate the identical ⌘F1 keystroke as typing it with your fingers, and/or the F1 key is weird because it has two key codes and sometimes maps to F13...
Couldn't get the AppleScript to do the mirror displays on, or a macro via System Preferences/Displays either. Think I am cursed.
Does anyone know what is wrong with thing AppleScript?:
I have been finding the same thing. i.e. Keyboard Maestro simulating the keystroke ⌘F1 doesn't do anything. Actually pressing ⌘F1 on my keyboard toggles mirror display (which is what I want). But I'd like to make the "toggle mirror display" a part of a longer Keyboard Maestro macro.
It is as if the System is refusing to let that particular shortcut be simulated.
It's not a huge problem as I can press ⌘F1 on my keyboard when I want to toggle the display but it is slightly frustrating that I can't do it through Keyboard Maestro.
I was wondering if there might be a way of doing it with a Shell Script Keyboard Maestro Action?
I know this is an old thread, but I was trying to figure out how to do this and came up with this solution, so thought I would share for anyone else looking for an answer. If you use "Simulate Hardware Key" action instead of "Type a Keystroke" and then set that to "Brightness Down" with the Command modifier checked below, it seems to work for toggle Mirror Display.