How to bind multiple macros, let them work together

I use three macros to do a job.
In part 1: use cmd+6 to click and hold the mouse button.
In part 2: use cmd+7 to move mouse cursor.
in part 3: use cmd+8 to release mouse button.
Please see the pics below.


Now the question is that, the hotkey cmd+7 and cmd+8 was already in use. So can I use these two keyboard shortcuts only when the part 1 is holding the mouse button?
I mean, if macro part 1 is not running, cmd+7 and cmd+8 are used for triggering other macros.
But if macro part 1 is running, cmd+7 and cmd+8 are for running part 2 and part 3.

I can easily use other keyboard shortcuts to trigger part 2 or part 3. But I want to solve this question for more KM knowledge. Hope friends here can help.

To test whether a macro can trigger other macros by their trigger based on your question:

Now the question is that, the hotkey cmd+7 and cmd+8 was already in use. So can I use these two keyboard shortcuts only when the part 1 is holding the mouse button?
I mean, if macro part 1 is not running, cmd+7 and cmd+8 are used for triggering other macros.
But if macro part 1 is running, cmd+7 and cmd+8 are for running part 2 and part 3.

The best way is to try it yourself since you already have the macro done, and then observe the behavior to understand them better. But one thing I do usually is simplify the test.

image

From what I experiment, macro does not trigger other macros by their trigger (eg trigger key, text typed) , which make a lot of sense, otherwise behavior becomes unpredictable and hard to debug.

I am a little it confused with what you say in your post, but as for now, i find a way and did test. it success. But actually the method is not elegant and simple.
Use a global variable to define if cmd+6 - Macro part 1 - is triggered.
In part 1, we set this Global__TrackThisQuestion to 0, means our three-body-macro starts.
We make a cmd+7 macro to check if the Global__TrackThisQuestion is 0, if yes, execute part 2, otherwise, execute another macro.
In Part 3, we set Global__TrackThisQuestion to 1.

Please see the picture below:

I did some test, it success. But i still think it's not a programmer's method.
Bind Macros_Backup_20220524_1705_v0.kmlibrary (12.3 KB)

1 Like

It would help to know what you're trying to achieve.

Macros only trigger when they are enabled.

If you use the "clashing" macros in different applications, create a Group for each app that is only enabled when the app is active and put the macros in the appropriate Group.

If they're to be used in the same app, for reliability you'd disable the other macro(s) using those same hotkeys and enable your part 2 & 3 macros just before your part 1 "hold mouse button" action, then disable the part 2 & 3 macros and enable the others after the "hold mouse button" action was complete.

Yu_Cai,

"Now the question is that, the hotkey cmd+7 and cmd+8 was already in use. So can I use these two keyboard shortcuts only when the part 1 is holding the mouse button?
I mean, if macro part 1 is not running, cmd+7 and cmd+8 are used for triggering other macros.
But if macro part 1 is running, cmd+7 and cmd+8 are for running part 2 and part 3."

From your description, my first thought is that you trying to trigger another macro through "Type A Keystroke" Action (in this case, you assign Cmd+7 to a macro) not Execute Macro Action because the way you phrase it sounds like it. My example is based on that understanding. Only when you explain further by showing your macro in detail that I understand what you mean, hence the confusion.

I think he's already got Macros A and B that use Cmd-7 and Cmd-8 as hotkeys. He also wants to have Macros 1 and 2 that use those same hotkeys. So Cmd-7 would trigger either Macro A or Macro 1, depending on current state.

Of course, I'm often wrong!

I must be missing something. What's wrong with this?

Click- Drag- Release.kmmacros (25 KB)

Macro screenshot

actually i also have a macro to move the cursor to the left 100 pixel(use cmd+9 to trigger). so i run part 1 to hold the mouse button, then run cmd+7 to move cursor to right, maybe press cmd+7 three times. then press cmd+9 some times, them cmd+7 some times agian, then cmd+9 some times again...then cmd+8 to release. in this condition, your method need further tests.

@Yu_Cai Try this:

Mouse Move.kmmacros (30 KB)

Macro screenshot

Mouse Move - Activate.kmmacros (20 KB)

Macro screenshot

Triggering the Activate macro with ⌘6 will enable the Move Mouse macro, which in turn will click and hold. Hitting the arrow keys will drag in any direction and hitting ⌘7 releases the mouse and disables the Move Mouse macro again.

I don't have a numpad, so I used arrows for testing. If this does what you want it to, then switch the triggers and Switch/Case conditions to suit your preferred hotkeys.