How do I setup a logical OR for a Pause Until action for keystrokes of
⌥⏎
~~~ OR ~~~
ESC
something like this:
The green "OK" is of course just a comment action.
Any ideas?
⌥⏎
~~~ OR ~~~
ESC
something like this:
The green "OK" is of course just a comment action.
Any ideas?
You can obviously Pause Until with a logical or by using the “any of the following are true”, but you want both an OR and an AND:
(Return Key Pressed AND Option Key Down) OR Escape is Down
To resolve this, just consider that Pause Until is really the same as:
Loop Forever can be done via While Calculation “1”
And to do an OR:
Break From Loop If is just If Then Else and Break From Loop.
Of course, you can extract the initial Condition1 into the Loop condition:
But I would probably prefer the symmetry of the two If Then Else actions, but it is a matter of taste.
You can also add a short pause to the While loop to reduce the CPU load at the expense of a small addition in lag (say 0.1 seconds for example). This is often a good idea for Pause Until actions, especially if the condition is expensive (which it is not in this case).
Exactly.
That should work!
Many thanks.
Chiming in here since this thread seems to be the closest thing to a solution for my problem I can find, however I still can't quite get it . The pseudo logic is helpful, I think I'm just having a mental block...
Similarly, I'm looking to continue or break a loop based on one of two key commands:
WHILE all of the following are true (Counter var <= StopLoopValue var)
{
Do ABC// at this point I am doing tasks manually for an indefinite period of time. This includes keystrokes, mouse clicks, etc.
Pause Until CMD+Return is pressed Counter+1, return to beginning of loop OR Pause Until CTRL+OPT+CMD+DELETE is pressed Break Loop
}
I'm struggling with is how to structure the conditional of the If Then Else in this situation. If we say "any of the following are true" with the following it will naturally undesirable results as any of the following will trigger true:
Modifier: CMD
Key: Return
Modifier: CTRL, OPT, CMD
Key: Delete
Is it possible to group these within the conditional as so?
Modifier: CMD + Key: Return
Modifier: CTRL, OPT, CMD + Key: Delete
Or, is there of a nested If Then Else approach I'm not considering?
@ JMichaelTX & peternlewis - I probably should have tagged you in my original posting, as I'm unsure how the visibility of a one year old thread's resurrection is handled. Any thoughts you have on this would be very appreciated
For detecting keystrokes, it is better to use separately triggered macros. If you want to capture the Command-Return, use a Hot Key trigger. If you want to just detect the keystroke but let it behave normally, use a USB Device Key trigger.
In any event, what you would do is:
The two other macros are simply:
Macro “Detect Command-Return”
Hot Key (or USB Device Key) trigger on Command-Return
Set variable “Command Return Detected” to 1
The reason it is better to use a macro trigger to detect a keystroke is because it is easy to miss detection of a keystroke since they can happen fast - trying to detect that the key is down may miss it if Keyboard Maestro is not fast enough, where as the triggers detect the key going down so cannot miss them happening.
Thanks so much! That was the breakthrough I needed. I can't emphasize enough how helpful it is to have you so active in the KM community forums!