MACRO: Toggle Between Macros

#Macro Library Toggle Between Macros

Toggle Between Macros.v1.0.kmmacros (20.4 KB)

Use a hotkey to switch back and forth between the two most recently-used macros. It is the equivalent of clicking the "Clock" icon in the editor (in fact, that's what this does).

I assign this to ^Tab.

NOTE: I published a version of this previously, but it contained functionality that is no longer needed, so I thought I'd publish a simplified version.

Here's the AppleScript, because this is all you really need.

tell application "System Events"
    tell process "Keyboard Maestro"
        perform action "AXPress" of button 1 of group 5 of window "Keyboard Maestro Editor"
    end tell
end tell
5 Likes

Very nice thank you Dan.

1 Like

Many thanks, Dan. :thumbsup:

Here is a related script by @ccstone, that allows you to select a Macro from the Edit History list:

These two make selecting Macros to edit so much easier.

1 Like

@DanThomas, or anyone, do you happen to have, or know of, a similar macro that will toggle between two browser tabs?

I don’t have anything already done. Perhaps @ccstone?

Thinking about how I would design such a thing leads me to this question: How would the macro know which tabs to toggle between? I mean, the current tab, obviously, but what tab do you switch to?

Good question.

One possible approach:

  • The first time you run the macro it records the current tab as the LastTab, and sets GotoTab to null (or empty string).
  • Each subsequent time you trigger the macro, it set the GotoTab to LastTab, and then LastTab to the current tab.
  • If GoToTab is null OR not found, then notify user to manually move to new Tab.
    • ELSE activate GoToTab

All that is just off the top of my head.

I'm sure I can write a macro to do this, but I just thought I'd check first to see if someone else had already done it. :wink:

@DanThomas, I have really enjoyed using your above Toggle Macros, and Chris' Display Recent Edit menu/Recent Run menu with a pair of macros triggered by my TrackBall FWD/BACK buttons.  After a little my real-world use/testing, I'll publish these macros.

I figured as much. Just thinking out loud. You're on your own. :slight_smile:

Hi @DanThomas,

When I fire this macro, it returns an error:

2021-07-25 22:36:52 Execute an AppleScript failed with script error: text-script:64:153: execution error: System Events got an error: Can’t get window "Keyboard Maestro Editor" of process "Keyboard Maestro". (-1728)

So, although I know very little about AppleScript, I tried to edit the AppleScript. I made it to work at my 2nd try!!!

tell application "System Events"
	tell process "Keyboard Maestro"
		perform (action "AXPress" of button 1 of group 5 of the front window)
	end tell
end tell

Awesome! But it was probably wasted effort on your part (other than a learning experience), because this "toggle" function and saving the position is now handled by KM natively, so you shouldn't need this macro anymore. :grinning_face_with_smiling_eyes:

Thanks. The menu says "Last Edited" and the Editor UI says "Modified". I did not know it was the same thing. :stuck_out_tongue:

I prefer the hotkey you use in the macro. So I'll use it but place the action with a menu click. :wink:

LOL. Been there.

That's what I did too. :smile:

1 Like