Storing list of coordinates in a variable to move mouse

I'm working on a project that requires about 360 unique clicks on the screen. I want to simplify my macro by storing all the X and Ys into a variable (or in a document and retrieving the numbers there) and then just repeating the move mouse action in a loop.

Here is an example of what I was thinking about doing, but it doesn't seem to work. Am I doing something wrong with calling the variable? Or is it that I'm storing the numbers in the variable incorrectly? I tried changing the variable to a "calculation" instead of "text" but that didn't make a difference.

Thanks in advance for the help!

(Note that I haven't put it in a loop yet.. I was just testing to see if it would work at all, and it didn't)


Try something like this.

Each line holds the mouse x position, mouse y position, and the amount to delay after the mouse move. You could read this from a text file, if you wanted to.

If you don't need a variable delay, then just get rid of the third number, and remove the magenta-colored actions.

By the way, my version here doesn't click the mouse button - it only moves it. I didn't want to click indiscriminately around my computer!

NOTE: The syntax I use, like MouseMove[1], only works when the variable is used in a Calculation field. That's why the third action (the first magenta-colored action) uses "Set Variable to Calculation" and not "Set Variable to Text".

2 Likes

This is perfect!. The delay is necessary as the clicks are inconsistent.
Thanks again!

1 Like

How could I get the 'screen area' dimensions into a variable like that?
the comma within the dimension itself is a problem. Is an extensive 'replace' method needed or is there a way to simply put it into a variable with all 4 parameters.
The following is what I'd like to get into a variable and then be able to use that variable in the 'screen area' dimensions.

The following obviously won't work:

Here's an example, with code.

###NOTES:

  1. I included two different ways of referencing the sub-parts of each variable.
  • Using the standard index method, like ScreenArea[1] etc.
  • Using "dot notation", like ScreenArea.left etc.
  • Obviously, you can use whichever makes most sense to you.
  1. I commented out the actual "IF"s, because I had nothing to test for. Because of this, I haven't tested the "IF"s, so if I mis-typed anything, you'll have to figure it out.
  2. In place of the "IF"s, I put in a couple of "Display Text in a Window" actions.
  • In these actions, I used the Calculate token so I could display the values in a text-based field. I had never tried this before - this is kind of cool.

Screen Areas List Example.kmmacros (9.6 KB)

Nice Dan, of course, … I didn’t think of ‘passing up’ using the WINDOW text inside the variable, thereby not needing to deal with the comma, very nice, thank you.
When I have a macro ‘looking’ at a certain area of the screen for an image match, I’ve found it nice to ‘highlight’ with a rectangle, that same area so I can see where it’s ‘looking’. I got tired of adjusting both the image search AND highlight ‘dimensions’ so with this solution I can just alter one set of ‘dimensions’ and both the image search and highlight will ‘follow’.
right then,/
Blessings for the New Year to you ~

1 Like