I'm looking for ideas on how to proceed with an project I'm working on.
What I think is the solution is to generate a display window with a bunch of lines of text, where each line starts with a single character that is the key to select that line. Like a menu, palette, etc. Then when I press the key for the first character on the line, KBM sets a variable, runs a macro, or whatever is needed.
The key issue is that I want the list to be dynamically generated, I don't want it to be "hard coded" like a list of defined macros is. I want to be able to change things in the course of my work and then I want KBM to run a little macro to find out the contents of the list based on what I've done and present the list to me to choose from. I don't want the housekeeping of having to manually go into my macro definitions to update the list before the current situation can be displayed in the menu.
Then, depending on the key I press based on the menu entries, KBM will do the appropriate things.
I think this may have various applications in addition to my current desire.
What I want to do with it now is to help manage all the different Desktops that I use. Right now I have seven Desktops in my laptop monitor and fourteen in my external monitor. I use the Current Key Stats program (free) to assign names to them all which are more mnemonic than the Mac Mission Control names of "Desktop 1" ... "Desktop 21". I have desktop workspaces for Email, Research, Project 1, Project 2, Project 3, Facebook, Money, Health, Music, Movies, etc. Sometimes in working on some internet research or software experimentation, it's useful to to arrange two Desktops side-by-side that I flip back and forth between. So I may temporarily change the name of a Desktop. I have a Logitech mouse with a tilt wheel and there's a setting where tilting the mouse wheel will move me left or right among my Desktops.
One technique I have found really useful is that I can move windows between Desktops by grabbing the window with the mouse, moving it a little, then pressing the hotkey to change windows and the moving window gets moved to the new Desktop. That's really handy. That's what I really want KBM's help with is being able to do all the hotkey-based Desktop selection with only my left hand while I hang onto the widow with the mouse in my right hand.
I got started with connecting KBM to AppleScript to Current Key in this thread:
https://forum.keyboardmaestro.com/t/how-to-get-a-currentkey-room-name-mission-control-desktop-from-applescript/21005. Where that just reports the name of the current Desktop (CKS calls them Rooms) using the
getactiveroom function, there is also a
getassignedrooms function which returns a list of all the current room names, separated by underscores. That's my KBM starting point.
Fortunately, there is a KBM plugin called SPLIT (
https://forum.keyboardmaestro.com/t/split-custom-plugin-split-a-string-to-a-km-array/21177) which will create a KBM array given that string and being told that the underscore is the delimiter.
So I want to use SPLIT to generate a list of all the current Desktop names and then have KBM wait for my keyboard input to tell it which item in the list I'm choosing, and then use the CKS AppleScript
gotoroom to change Desktops.
The part I'm having trouble outlining is that last part: how to read a single keystroke and set a KBM variable or choose an action based on that.
I can do it with a KBM palette, but to make that work I have to have the CKS names of the various Desktops hard-coded, I cannot change them on the fly, while I'm working on something else. Any time I change a Desktop/Room name I would have to go into the KBM Editor and update that palette.
Anybody want to brainstorm some ideas with me on how to do this?