Move the Cursor, Do Some Actions, Move the Cursor Back, Move It Down 13 Pixels Each Time Through

Been looking through the forums for hours and striking out.

I need to select an item on a web site. Just by clicking it, it takes you into the item's details. Then I make some changes to the item (this part's no problem). Then I need to click back and (here's the tricky part), select the next item. This is easy to do once, but each time I go back, I need to move the cursor 13 more pixels down than the last time. I've tried setting a variable to zero, then adding 13 to it in each loop, then setting the mouse Y position to that variable. But things just aren't clicking.

Please help! I will be so grateful.

The best way to get good help on automating your workflow is to:

  1. Post the URL of the web page to be processed (unless it is sensitive), and to identify which browser you are using.
  2. Post the KM Macro (file and image) you currently are using
  3. Be specific about which step/Action is not working for you.

Generally it is best to use found image and/or movement by pixels of the mouse as a last resort. It is much better (more reliable), if you can, to use KM Actions and/or JavaScript in Browser to click on the web page elements of interest.


Thank you for the reply. The web site is actually very sensitive as it’s a large corporate password management system. I could post the macro but right nowve as it’s a large corporate password management system. I could post the macro but right now it’s literally one step - click at this position. If i can’t figure out how to loop through and add 13 pixels down to each step I have no reason to go further and we’ll have to edit the 700ish items by hand.

I’ll review the materials you referenced and see if I can come up with something. Since each item is text with a different name and some JS that takes you to the account page when you click on it, I don’t know how to use the find image function for that.

You can use the MOUSEX() and MOUSEY() functions to get the initial mouse location. And then you can add 13 to it each time and use the Click action.

So something like this:

  • Set Variable X to calculation MOUSEX()
  • Set Variable Y to calculation MOUSEY()
  • Repeat
    • Click at X,Y
    • Set Variable Y to calculation Y + 13

Sure enough that worked perfectly. Thank you so much. Seems so simple when you did it yet I spent hours trying wrong things. Sincerely appreciate it!

1 Like

Everything is easy when you know how, and difficult when you don’t. That is what makes forums (especially this one!) so valuable.

1 Like

I had to automate some complex Webpage interactions. I found a couple of things useful.

Store X,Y as a variable:

Set Variable ‘MouseCursorPosition’ to Text
%Calculate%MOUSEX()%, %Calculate%MOUSEY()%

And save each mouse cursor repositioning macro as it's own macro, called from the "parent" macro. (I named parents as Name.1.x.x, children as Name.1.1.x, and grandchildren as Name.1.1.1.) This allowed me to

  • More easily adapt each multi-step macro to changes in the display on which the Webpage was displayed or to changes in the Webpage itself

  • Use the repositioning macros in other similar macros run on other Webpages

  • Save versions for re-use.


Hi, i'm just new here. Could you explain better our method? I'm just gettting started here! :wink: thank you

I'm not sure how to explain it further. Have you done the Tutorial? If you know how to create a macro, and how to add actions, then you basically just add the actions as described:

  • Use the Set Variable to Calculation action and the MOUSEX and MOUSEY functions.
  • Use the Repeat action with a number set for the number of times to repeat.
  • Use the Click Mouse action to click, and use the variables from earlier (X and Y) as the location to click. Ensure you configure it to click relative to an absolute position, since that is what the MOUSEX and MOUSEY functions return.
  • Use the Set Variable to Calculation action to set the Y variable to the calculation “Y + 13”.

Hey @Rick_4,

You just can't explain this sort of thing with words in a way someone who isn't conversant with the software will understand.

Here is an example macro for you to dissect and figure out how it works.

Run it, and you'll see the cursor move by steps.

After importing the macro be sure both it and the macro group it's in are enabled in the Keyboard Maestro Editor.


Move the Cursor by Steps v1.00.kmmacros (9.8 KB)

1 Like

Thank You so much Chris! You perfectly got the point, a new user is not handy yet and needs a graphical visualisation!

1 Like