Wait until trackpad is released

In Quickeys, there is an action that pauses a macro until the trackpad has been released. This enables the user to move the cursor to a chosen position before the macro is resumed. Is there such an action in Keyboard Maestro?

No, but you can use the "Until" action this way:

Here it is set to half a second (that is it will pause the macro until you're idle for half a second), but you can adjust it to fit your needs (i.e. 0.25, 1, etc.).

You'll probably want to precede that action with a "Pause for 0.5 sec" or "Pause for 1 sec" action, so the "Until" action won't see you as idle before you start moving the cursor.

Many thanks for reply.

That kind-of works, but the length of time I need to pause the macro for will vary and this solution apparently doesn’t allow for pause length to vary

Well, this method will pause the macro until you stopped moving the cursor for longer than the value you test against. So the pause length will indeed vary depending on your actions.

Why not pause until you press a key— align the mouse and then tap F19, for example. What exactly are you trying to click on? Perhaps Keyboard Maestro can click it for you with the Find Image on Screen action.

Here is a screenshot of the Quickeys shortcut I'm trying to replicate. It allows me to select something (for example text), move my mouse to a chosen place and the shortcut will paste the text at the chosen place. Can Keyboard Maestro replicate this shortcut?

Sure, you can do that. Use the MOUSEBUTTON() function to determine if the mouse button is down. Pause Until it is down, then Pause Until it is up.

1 Like

It sometimes works, but its a bit temperamental. The same movement of the mouse seems to produce different behaviour each time, and sometimes it doesn’t paste at all.

I’m on Yosemite beta - are there any known issues?

I’m actually using the trackpad on a Mac, not a mouse - will this affect how macro works?

If you are clicking quickly, then its possible the pause will not see the down press.

To ensure you can catch the release, you can use a separate device key trigger. The device key trigger can detect the mouse button (and I presume it will detect the trackpad button as well). Do something like this:

Yep that appears to have done it. Brilliant.

As an extension to the copy and paste shortcut discussed abobe, I'm hoping to replicate a similar shortcut. This shortcut also copies/pastes, but it keep on pasting until the shortcut is stopped. A screenshot of the shortcut as implemented in Quickeys is below. Note how step 3 keeps going back to step 2 until the shortcut is stopped.

You use the various Flow Control actions to control repeating (While, Until, Repeat).

Its not clear what your repeating condition is, but perhaps While a key is down would work.

Alternatively, the hot key can be repeatedly retriggered while the key is held down. You want to avoid the Copy except the first time, but that could be done by tracking the time - not trivial, but then duplicating something in a particular way is often more difficult than finding the natural way.

I’m not sure what the natural way for this would be - myself I would probably use two triggers. Actually, I would probably just do the Copy myself, and then click and then apply the trigger, at which point a repeating paste would be easily down.

But certainly its possible to do what you’re describing.

I've had a shot at making a macro that repeats the copy/paste macro discussed above. I want to be able to select something (for example text), press F7, then have the thing I selected pasted everytime I release the trackpad:

The above macro does what I want, but pressing to stop pasting seems quite temperamental. If I bash quite a few times, the macro stops pasting. But simply pressing once doesn't seem to stop the macro. What I now want to do is simply press once to stop the pasting action and also not have ` be typed.

Any time you use the “This key is down” action, you’ll need to ensure you will be holding the key down load enough for Keyboard Maestro to get to the action.

One way to resolve this is to create a second macro with a Device Key trigger (so it sees the key but does not intercept it) which sets a variable (eg Set Variable “Backquote Pressed” to 1). Then in your macro above, you would do:

Set Variable “Backquote Pressed” to 0
Execute Actions
Until Variable “Backquote pressed” is not 0

Since the trigger will detect the key being pressed there is no issue with how long you hold the key down.

Its been a while, but I've had a go at implementing this macro. To recap, I want to be to select some text and then click anywhere on the screen and have the text pasted. I want to be able to paste the text everytime I click on the screen, until I press ` which will stop the macro.

I created the second Device Key trigger macro:

I then amended my macro as follows:

My macro now pastes the text once when I click on the screen but does not paste thereafter. What am I doing wrong here?

The Set Variable “Background pressed” to 0 and Type the Command-C Keystroke actions should happen before the Repeat Until action.

It could be that the Command-C being repeated is emptying the clipboard (most applications will just beep if you Command-C with no selection, but some applications might clear the clipboard.

I'm one step closer! The macro below does what I want - it repeatedly pastes whatever I've copied. However, I cannot get the macro to stop (the only way to stop it is by closing down Keyboard Maestro). Or in other words, there's something wrong with 'Backquote pressed' variable. Can you see whats wrong?

Backquote pressed is set by the other macro (the one called "Set Backquote pressed to 1").

Make sure that macro is firing.

I've resisted posting about this again and tried to figure out what's going wrong. However, after fiddling with the macros and reading the documentation, the macro is no further forward (in fact I've moved a step back, because it's now pasting once only).

This thread is likely becoming annoying now, but any advice would be much appreciated.

What I'm guessing is the problem is the bits that say "1 -> 1" and "YES -> NO" at the bottom of the macros (circled in red). I cannot figure out how to change these:

The "YES -> NO" simply displays the current value of the variable and the current value the variable would be assigned if the action (and no other actions) was executed right now.

So "1 -> 1" means the "Backquote pressed" variable currently has a value of 1, and of course will be assigned a value of 1,

Similarly the "YES -> NO" means the "Mouse Up" variable currently has a value of "YES", and of course will be assigned a value of "NO".

I say "of course" because the values are trivial in these case. Where this facility comes in to the fore (aside from showing you the current value of the variable) is when the new value is a token or a calculation whose value may be non-obvious.

Where it can be misleading is the fact that its value is calculated solely based on the current state, but the actions before it may affect the value. For example:

The second action will always change the variable from 1 to 2, but until you run the first action the value of A remains "B" and the calculation and result shows as invalid.