Is this possible? One keyboard trigger to toggle two separate actions?

Basically.. my use case scenario: I want the trigger CMD+' to toggle between two screens layouts in a reference manager app. Just wondering if it would be possible to set this up somehow via a script or something? Natively, screen 1 and screen 2 are able to be triggered by their own keyboard shortcuts. I basically want to path CMD+' to toggle between the two.

Not sure if I'm making any sense here...

Yes. Whatever method you use to create the keyboard trigger, e.g. BTT, macOS inbuilt shortcuts, etc., you write out a flag value to a file that tells you what the last action was performed when last triggering the hotkey. Alternatively, you can get the current layout and determine the appropriate action to take based on this.

Either way, a tiny bit of scripting.

Appreciate your help! I must admit - scripting is completely out of my expertise. Any resources you'd recommend on where to start?


In that case, you might wish to use as many of BTT's built-in features for as much as you can. Since it sounds like you have shortcuts set up for screens 1 and 2 separately, it may be simpler to piggyback onto these, so that pressing your unified shortcut goes on to trigger the keyboard shortcut of the screen layout you want to adopt.

But without knowing details of, well, everything, I can't. Offer specific solutions.

I can show you how to read and write data out to a file, but thinking about it, BTT has global variables that you can use instead, so that avoids having to script that.

If your toggle depends on what the current layout is, you need to determine what is specific to one layout that distinguishes it from the other, so you know what to tell a script to look for when deciding which value to toggle to. It might be they each take you to different screens, which would be an obvious distinction.

Otherwise, I don't know what specifics will be useful.