Hot Key Macro With Nested If-Then's: Is there a faster way?
I've made a hot-key macro to use the escape key like a light-switch of sorts— to, depending on what is selected, either enable a disabled action, disable an enabled action, enable a disabled macro, or disable an enabled macro. I've done this with nested If-Then's. My first inclination was to use a switch but 1) distinguishing each case requires two conditions to be met, and 2) the conditions I'm using are menu conditions which I learned aren't available in switches.
It works, but with a lag of several seconds– Long enough that it's not really a shortcut, currently.
Willing to guess one of the advanced experts here will have insight I'm missing as to how to make this run faster.
Yes, there are much faster ways to do this. The way I go about it is with a straightforward regex that uses the appropriate menu item regardless of what's currently selected:
Enable:Disable.kmmacros (2.5 KB)
Thank you! That is perfect– And it would not have occurred to me to use regex to select a menu item! I can see this being useful for other things.
I have been using this RegEx Macro all week its fantastic.
Trying to re-purpose it to Expand / Collapse actions, I've adjusted it but truthfully I don't know anything about RegEx so I must have missed a step. Anyone know what I missed?
Collapse : Expand Action.kmmacros (57.5 KB)
Well, you would have to tell us what you are trying to do.
And then, what is the result of the Macro, and what do you want different.
I think you can do this for Expand/Collapse Actions without Regex. The reason we're using Regex for enabling/disabling actions/macros/groups is because those all share one menu item that changes depending on which one of those things is selected, and whether or not it's enabled.
Expand and Collapse actions on the other hand are two separate menu items that both always exist and are enabled/disabled (Note: I might be wrong about those terms, it might be marked/unmarked or something else), depending on what is selected. So I'm speculating that you'd be able to map them to the same hot key by creating a toggle that switches based on which of the two is enabled or marked.
Not sure if I'm making sense, but hope this helps.
I'm such a bozo.
Basically I just want to use the same key to Expand // collapse the selected step in a macro based on what is available.
Right now I use the attached image, just figured going the RegEx route would be better.
I see nothing wrong with your macro. I doubt it could be made materially more efficient.
Just enjoy it, and move on to other tasks.
Well I am not one to disagree with an expert! Thanks for taking a look!