Can't get mouse click to work?

Hi Guys,
I'm trying to create a KM macro that clicks a box on Nuendo (a DAW), inserts text and then presses return.
I initially couldn't figure out whether KM was actually moving the mouse to the right position (which I tried first with a position and click), and so used an image instead.
With the display option checked, I can see that it finds the right location, however still no clicking seems to occur.
I've added a pic of my Macro - what am I doing wrong?

I've insert pauses as I wondered if the actions followed each other too quickly, but it doesn't appear to make any difference.

The clicking will happen -- but you've set an offset of 10 (nominal) pixels below the centre of the found image. Might that be outside the bounds of the text box? Difficult to to tell with an image of the UI, but try setting both "Click at" numbers to 0.

I've had this problem with KM mouse clicking in certain apps and found a solution was to break the mouse actions into two parts - one mouse Action to move the mouse to the right place, a pause, a second mouse Action to click at 0,0 to the mouse location.

2 Likes

Thanks Zababon, I'll try that!

Thanks Nige, unfortunately even setting it to 0.0, it didn't work...

I'm often confused, so blame me if I'm wrong here. When I read your original paragraph, you talked about "clicking." Then when I looked at your macro you were doing "double clicking." Then Zabobon's code indicated single clicking, which you said you tried. So I'm confused.

For this post, I'm going to guess that what you want is double clicking. If your app isn't working with the KM action that "double clicks" even when Zabobon's Pause is inserted, then try "two single click actions" each preceded by a pause action, perhaps 0.25 seconds to start.

Many apps are finicky the way they accept mouse clicks, probably because they use non-standard APIs to detect mouse clicks, but I've never seen an app that I couldn't trick into accepting a mouse click.

Hi Airy,

I was trying both. It seems this box accepts either, and I was trying different clicks to see if it made any difference.

I've tried breaking up the Macro into separate clicks but still no joy. Wish there was a way to see which pixel is being clicked - KM shows the recognised image correctly but anything after doesn't appear to work.

A long shot here @Joris_de_Man1 : I've noticed that with some apps the click at found image action fails to work too. What seems to happen is the click "wakes up" the app and it then requires another click to work. I've seen this happen with Safari and some cross platform apps too.

The approach I take in this situation is this:

  1. First activate the app using the Activate a Specific Application action.
  2. Then use the Move and Click at Found Image action as desired.

Like this (just an example - this needs to be configured for your situation):

image

If this approach works for you - great :grinning: If not - well you might try adding a short pause between the two actions... like I've had to do sometimes :frowning_face:

1 Like

Generally speaking, Pause actions will solve many problems like this, but rather than guess at the duration of the Pause action, I usually place a test in a loop to evaluate whether the system is ready for the action following the Pause action. So in this case, I would write this code:

image

Whenever I write a macro, I look within it for any "constants" and try to replace all my constants with improved code that doesn't use a "constant." I find that constants are usually "assumptions" and we know what happens when someone makes an assumption.

That action of yours will keep activating Safari until it comes to the front - which is what a loop does.

I like your thinking though - so I would use the Pause Until action after the activate action

image

That way there's no danger of performing many activates...

Sure. That code is probably better in this case. I was just trying to get across the idea of avoiding the use of constants. In this case, the "Pause constant" will have to have a minimum value, and it's not easy finding what that minimum value is. The minimum value could even change, based on CPU usage, graphics resolution, and other values. In that sense, using a Pause statement is "dangerous" because it could fail to work if you don't guess correctly. I could probably write a very long post about how to eliminate constants from macros.

Turn off the option to Restore the Mouse Location, and then optionally add a Highlight Location action.

1 Like

Thanks Pete...the plot thickens...

So, Find Image definitely finds the image, as it lights up the correct section.

None of my mouse clicking events seem to work, even with pauses.

When using the 'locate mouse' option, it highlights where my mouse pointer is, which is not near the box I'm trying to click, even if I try and move it there.
I've tried different options

That said, even if I move the mouse to the location where the box I want to click is, the mouse click event doesn't appear to work and clicks don't seem to hit anything.
A single click with my actual mouse does allow the text field of this box to be filled.

So I'm at a loss as to what's going on here...

Question: I'm assuming that the Move Mouse function actually physically moves the mouse pointer?
Or does it do it so quickly and then restore the original position that you don't really see it move?
Just noticing that my mouse pointer never moves to the desired location with any of these commands...

Cheers,

Joe

You're running around in circles with too many things you can't answer, so you need to focus on them one at a time.

For the click at found image to work, these things have to happen:

  • The image has to be found
  • The mouse has to be moved
  • The click has to be simulated
  • The system/target application has to accept and handle the click event

So test this one action. Create a macro with a simple hot key (ideally without modifiers for testing purposes, since modifiers can affect some application behaviour) and just this one action.

Configure the action so:

  • Wait for Image is off
  • Restore Location is off
  • Notify on Failure is on (verify that notifications are displayed - test using the Notification action).
  • Display option is on
  • Image match is Unique (ideally)
  • Action is set to Just Move

Switch to the target application and trigger the macro.

Does the mouse move to the correct location? If not, resolve that before proceeding. Check the Engine.log file to see if any error is reported that you have not seen (typically because Notifications are not being displayed).

If it moves to the correct location, the configure the mouse to Click, switch to the target application and trigger the macro.

Does the mouse move to the correct location? If not, return to previous steps. If so, does the click happen?

If the click does not happen, but the mouse is in the correct location, check the Engine.log for any indication of issues. Ensure it shows the macro being triggered. If nothing else appears, then disable the action, create a new action that is simply:

  • Click 0, 0 relative to the current mouse location
  • Restore Location is off
  • Notify on Failure is on (verify that notifications are displayed - test using the Notification action).

Switch to the target application, move the mouse to the correct location and trigger the macro.

If that does not work, the either the application is misbehaving, or you have Accessibility Permission Problems.

Try the same “just click” macro in any normal application (eg the Finder). If it does not work there either, then likely the issue is accessibility permissions.

1 Like