Begin Running Macro at Specific Step

I have a macro that has 17 possible starting points (starting point #1 being most common). One option is to simply disable all of the steps before the starting point I want to begin on. But I'd like the macro to be a little smarter if possible.

In the attached screenshot, each starting point is in teal (labeled as "position #").

Is it possible to start off by asking the user which position they want to start on (1 through 17), and then having the macro begin at that specified step? I assume I'd need to add some kind of action to trigger the starting point at each of the 17 specified steps. Is anything like this possible? If so, is it too complicated to setup?

Take a look at the Switch/Case Action.

1 Like

How does the user know where to start? What are the different options? Can you remove some of those options by checking the state of the computer, what's on the screen, something else?

Once all that's sorted you can use the "Prompt for User Input" action to get the user's choice(s) and, as @mrpasini says, "Switch/Case" and "If... Then... Else..." actions to branch through your code depending on their answer(s).

It's a bit silly. This isn't work-related and just for a video game. I play WoW with a few buddies and to fill a group of 5 people for a dungeon, I'm always in charge of finding 2 extra people (of a specific level and class). This macro will simply message every person from a query to ask if they want to play with us.

Instead of manually asking people with a copy/paste chat message (which is exhausting), I made this macro to automatically ask every person found within a query (see attached). The query listing can return up to 50 players, showing 17 players per "page".

Each position is represented by a player in the listing. Technically, I could scroll the page so that it asks 17 people every time I run the macro, but then I would be asking some people multiple times, which I don't want to do. So this thread-post was just a way of finding out how I could start my macro on a certain player and continue down the list, without asking the same person multiple times.

I'll get a chance to test out the Switch/Case during lunch.

It works beautifully. I wasn't sure how to set it up so I just kinda guessed my way through it. I prompted User Input with "Position" as a variable, using a default value of "1", and put each of the 17 position-set-of-steps into their own Switch/Case to look for Position <= its position number, and it worked exactly the way I was looking for. Awesome!!!

Thank you very much.

1 Like

Congrats!

1 Like

I can do silly!

How about this approach instead? If everyone's in the same zone you can use a "Found Images Collection" to get the click locations rather than hard-coding them. Then you just skip the items in the collection prior to your required start point.

I was working off your screen shot so you'll want to capture your own image and play with the fuzziness to get a good match. I've just moved the pointer then paused for each player you'd message -- replace those actions with your click-and-message ones:

WoW Test.kmmacros (24.3 KB)

Image

If you don't want to use found images you can combine your hard-coded locations with my loop -- instead of a collection of images put your click locations, X and Y comma separated, into a variable and go through that line by line:

WoW Test Numbers.kmmacros (7.7 KB)

Image

Lots of options!

1 Like

Cool! I love that second macro with the hard coded options all in one dialog box. It's so much cleaner than my book-long macro.

The location will vary as I only query class and level range (i.e. if it's a level 20 dungeon, I would query "18-22 priest" for example to find a healer), and their location could be anywhere in the world.

Can't wait to try that when I get some time tonight.

I wasn't able to get it working. I don't understand anything going on there, so I'm having a hard time modifying it. I need 2 clicks for each player:

  1. moving the mouse to right-click the name, to open a pulldown menu. These are all absolute positions.

  2. moving the mouse to left-click "whisper". This is a relative position to each absolute position, always 35px right and 135px down.

As soon as whisper is selected, it opens a text field ready for text-entry; no mouse-movement needed.

Note: 35 down and 135 right might not look correct judging by that screenshot, but for some reason, my screenshots are saving out at a higher resolution than my game. I don't know why that's happening; it's why I had to record all of my actions in one go instead of creating each step manually.

Post your not-working macro so we can see what the problem is -- instructions are here.

I reckon that not only can it be fixed, but also that the hard-coded bit can be further simplified...

Attached are the uploads. Local_imageList are the coordinates for right-clicking each name in the list. A left-click first, before a right-click, would be ideal just to retain visual feedback that each person is getting clicked on. It also lets me know the final person who was messaged so I can quickly scroll down to the next set of names and immediately re-run the macro.

The steps in red are ones I added. The "pulldownList" step are the coordinates for all of the left-clicks within the pulldown menu.

Currently, the macro selects each person and just goes down the list.


WoW Test Numbers.kmmacros (8.7 KB)

Do you have a Retina display (or similar non-Apple kit) by any chance? If so you're falling foul of the difference between actual screen resolution (your screenshot) and nominal screen resolution (what the OS, and therefore KM, uses for window/pointer/other coordinates).

Skip all the hassle by using KM's "Mouse Display", available in the Editor's "Window" menu, for this type of thing. There's even handy "anchor" buttons so you get the coordinates based on eg top-left corner of the active window, which saves a lot of maths!

OK, so let's have a re-think and try and make it easier.

The first line of the list is always in the same place relative to the top corner of the window. Each line is the same height. So instead of of maintaining a list of places to click we only need the first-line coordinates -- line 2 is the same X but n pixels lower down, line 3 is another n pixels lower, and so on. By my estimate, n is 21 pixels.

Your "Whisper" option is always 35px to the right and 135px down from where you've clicked on the line -- so we don't need a list for that either, we can just offset from where we clicked.

Putting that together with what else we know, our plan is

start with line 1  X and Y coordinates
set i, our loop counter, to 1
repeat while i <= 17 -- the number of lines in the list, so we stop after the last line is processed
   if i is less than the number we want to start messaging from
      do nothing
   else
      click at X,Y to hi light the line
      right-click at X,Y to open the menu
      click at (X+35),(Y+135) to select "Whisper"
      paste text
      simulate the Return key to "Send"
   end if
   set i to i+1 -- incrementing our line counter
   set Y to Y + 21 -- so we are basing our clicks one line lower than last time
end

And we can pretty much take that and translate it, step-for-action, into a KM macro:

WoW Test Single Position.kmmacros (12.6 KB)

Image

I've used your numbers from earlier for Local_startPoint, the line height, and the offsets for the "Whisper" menu item -- you may have to finesse those. I've left long pauses between each UI action so you can test and I'm assuming ESC will cancel the "whisper" so you don't spam a bunch of people when testing!

Hopefully you can make sense of what's happening, and my explanation hasn't made things worse! Give it a go yourself, and holler if anything's not clear.

1 Like

It works brilliantly. Thank you for explaining how each step works; I've read through it slowly about half a dozen times and understand what's going on, but translating that into the macro steps is where I get lost. I can see each step, but trying to interpret it is like looking at another language.

Just coming up with the method to put it all together like that boggles my mind.

Thanks again.