Hello everyone!
I'm using and loving KM9 but I'm stuck with a particular conundrum. I have an interface where I have 16 or more instances of the same icon on the screen at all times. I need a way to pick out just one of those. See this image:
I need to click directly on the fader icon relative to my selected track (A15). I have tried using Find Image to store the highlighted track's location as a variable and calling that position to set mouse location. However, I now need to tell KM9 to click the fader that corresponds to that selected track, rather than finding any of the others (leftmost, rightmost, topmost, bottommost) because those positions will be constantly changing. My hope is that I can use "click found image > best relative to current mouse location" or something like that. Is there a workaround? Something I'm not considering?
Very much hoping there is a solution to this because I have countless applications for this functionality. I'd also like to use the same technique to click ALL instances of a found image (i.e. each of the square icons at the top one by one).
Thanks for the help!
How do you identify the "selected" track? Looks like you have two tracks highlighted:

I'm not sure I understand your logic or proposed workflow.
If you are already moving your mouse near the target "fader", why not just click on it?
But to directly answer your question, yes, you can use one image to help find another:
- Use a Find Image on Screen action to find and get the frame of the first, reference, image.
- Then, assuming that your second image is always in a specific area relative to the first image (one of its corners, or center), then use the Move or Click Mouse action using the "relative to area" option, and enter that area relative to the first image location.
Make sense?
1 Like
Thanks for the help!
A quirk of Avid Media Composer is that you have to click this fader button
in order to make audio changes without stopping playback. That's why I have to click a second time and that fader button will always be somewhere different. However, given that it will always be located directly above the selected track button, I came up with this solution to find it based on a pixel color. It's not elegant, but it works. 
Regarding this:
- use the Move or Click Mouse action using the "relative to area" option, and enter that area relative to the first image location.
How do I do this, exactly? I thought "area" was relative to the total screen area. How to I tell it to click an area relative to the previous found image?
Thanks!
Here's an example:
MACRO: Use One Image to Find Another [Example]
~~~ VER: 1.0 2019-08-28 ~~~
Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
DOWNLOAD Macro File:
Use One Image to Find Another [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.
Macro Setup
You will need to make these changes
- Replace the images in both Find Image Actions with your images
- Change the offset to the First Window center in the second Find Image
- Assign a trigger
- Put macro in a Macro Group that will be active when you need it.
- Enable both Macro and Macro Group.
3 Likes
Oh man, awesome! Can't wait to try this, thanks!
This works! Thanks!
However, is there a way to make it recursive somehow so that the result is changing the offset of the macro itself? Find the coordinates of the next leftmost image to the right of the one already found and set that as the new area limit. Then, find the one to the right of that one, set new area limit... etc and so on. There may be two images, there may be twenty, impossible to predict so I can't just assign a per track variable and go in a row. Or can I? Is there a function in KM to Set New_Variable name to Old_Variable+1 ? That would work!
Thanks again for the help!
P.S. One note for future searchers about the macro JMichaelTX linked. It failed until I took the spaces out in MidX + 30 and MidY + 20 (to MidX+30, MidY+20)
You must have changed something else. The macro ran fine for me just as I uploaded it to you. Spaces in the calculation field are irrelevant.
1 Like
Of course. Just make the offset be a KM Variable, and increment it by the offset of the next image.
But how will you determine when you have found the one you want, or the last one?
1 Like
Thanks for your help! I figured out how to do it and it's working great. I did an Execute Until macro that keeps moving the area boundary further right until no more selected tracks are found. The way I built it is probably clumsier than it needs to be but it works like a charm!
P.S. Not that it matters but I just did a test; I went into my working macro and added the spaces in after MidX and MidY and it indeed failed. Not sure why it's different on my system, perhaps this is a setting?
Spaces are allowed in calculations (outside of variable names), so I have no idea why that would be failing (unless you are putting in "hard spaces" or some other weird invisible character).
1 Like