How Do I Add a Condition of Key with Modifier to IF/THEN Action?

How do I add a hotkey condition in "if then else" action? There is only "key" condition which detects single key tap, but I need this to be two or more like command+x.

1 Like

@4123125121 You add a "These Modifiers" as another but separate condition using the green cross.

Look for the 'These Modifiers" in the drop down list you found "The Key" in. Make sure you set the whole set of conditions to "all the following are true". Then the action should only execute if all conditions are met. It is like a hot key in many ways, and behaves often like one. It isn't a hot key though and just kind of emulates one. The macros will often become tricky because they will be wating for a set of conditions to arise and keep running I have found.

The macro will run differently from one run from a hot key trigger and I try to be very aware of that. So I try to use a 'stop macro' action after setting an 'if else' flow that way.

Just a discursive off topic point too :wink:
I can make useful triggers for myself this way that I use a lot, because the macros will truncate text strings if you lift a key or add one during a sequence of text insertions. I need sometimes to pay close attention to my surroundings while triggering text entries with a lot of possible extensions. So I effectively time sequences out.

1 Like

There is a possibility that you press c somewhere but it does not appear. You want to type a word including 'c', like "cat", but what you get is "at" even if you did not touch the command key.

Tell me what you are trying to do with this macro and we might be able to help you more. Check in all your macros that you don't have a hot key that ONLY uses the "C" key. If you have it will trigger something that you might not be seeing and it is short circuting the normal use of the key.

ALSO If you make sure that after "if" at the top of the box it says "all the following are true". You might have it set to "if any of the following are true": that is no good and you will get terrible results, it will trigger every time you press either 'c' or 'command' and really mess stuff up for you.

This is not really a 'hot key', it is set of conditions that are being looked out for while the macro runs. They will when satisfied, act as a kind of 'trigger' but don't think of them as 'hot keys'.

The issue here is to look out for conflicts with other hot keys you use and other macros.

Upload if you can a picture of the macro you are trying to
make. Don't upload the actual macro just an image. Here is how to do that.

I am sorry, the situation I described only happens with the hotkey as the trigger, not the "if-then-else" condition.

Anyway, I want to set a useful trigger so that the hotkey is enabled only when a certain application is activated( at the front ), so that the new hot key does not pollute global field, which may mean that command+c is Copy in other applications while Cancel in a certain other application. I tried the "application is active" trigger, but it checks status periodically which I think is not what I want, for apparent reason: what if the time I press the hotkey is not exactly the time it checks status? this could happen even if I set the cycle to be 1sec, let alone the CPU waste on that.

If you want a hotkey active only in certain applications, make a Group and set it up like this:


Then any hotkeys you set up will only work in the specified applications. I've NEVER seen this have a delay. It just plain works.

1 Like

@DanThomas is exactly right. He might correct what I say too, he is more expert than me.
I reply really for another reason, your use of single letters as TRIGGERS, especially in text documents seems a very bad idea.

This was though my own suggestion imaged below. This one works fine from a palette and responds to HOTKEYS too. Dan said all you need to know though. I will put in big letters terms specific to Keyboard Maestro and that have specific meanings because it is confusing otherwise.

You need to put your MACRO into a GROUP like Dan suggests. Even if it is a GROUP with just one MACRO in it, it will still make things work better.

In my example the shortcuts will only work in a FOCUSED WINDOW that contains the word "Untitled". You can set as Dan shows of course and not make it window specific.

However I reply again because I would suggest that since it seems you are working in a text document or at least entering text; using "c" as a TRIGGER of any kind is going to make it unusable to enter text with: that is exactly why one needs MODIFIERS. Let us know if you have trouble translating what we say will you? We will find a work round. Apologies if I am wrong but I feel you are more familar with another language than English? If you really want I can upload, especially if Dan or the experts think it is ok. But I won't upload it with single letter triggers.

Here is a screenshot of my GROUP as it looks when you have it in the EDITOR

Screen Shot 2019-09-07 at 14.19.38 PM.png

Can I make sure of something @4123125121 before we move on?

Select that box which contains "C" in the actual macro this is an image of, click in it, it should highlight, then press Cmmd + c both at the same time: that should enter Cmmnd + C as your Hotkey. Then follow Dan's advice. That should make Cmmnd + C usable in the chosen apps without causing problems using the "C" key alone. The way you record or set up Keys is different in if then actions than it is when setting a Trigger: which is what you are showing in that image.