Set Found Image for 20+ Actions?

So I'm trying to create a macro that will have 20 actions that work with the same image. The image is the same for all of those 20 actions but I'll need the to change that one image semi-frequently and would love to change it with only one action instead of changing it for all 20. Anyway to do this?

Some excellent ideas and examples here:

1 Like

As of KM 9, if the image is a file you save to your disk, you can set a variable to the file's path and have your actions reference that file:

29%20PM

But if you'd rather include the image itself in the macro without saving it to disk, you can set a variable to the image's coordinates after the initial action that uses the image, then use the variable with all subsequent actions:

image

This way, you can change out the image in the initial action whenever you like and the other actions will reference that same image's coordinates.

Further Reading:

1 Like

Perfect, heading down the right track, a couple follow up questions on the variable method

  1. How would I use this doing If function with a found image condition. I tried doing it as a variable condition but couldn't figure out how that worked

  2. Using the the move and click function how do I format a click that's 55 up and 55 right from the image? Local__Image.55 didn't work

To answer the easier question first:

Assuming you want the center of the image as your starting point, you just need to add and subtract 55 from each value, respectively:

image

I'm afraid I need some more information here about how exactly you want to use the If function and found image condition. Depending on your desired workflow, you may need to go with the file-saved-to-disk version, but again, I can't say for sure until I have a better idea of what exactly you're trying to do.

Thanks on the first part,

If I were to do it normally I would just do "If the screen contains image then execute the following actions."

No problem. If you want to make use of "If found image" conditions like that, I think your only option may be to go with the file-based version. To do that, you just need to set a variable containing the image's path at the beginning of the macro, either manually or with the Prompt for File action:

Find Image Using File.kmmacros (4.9 KB)
image

2 Likes

This still would work great and definitely solves the issue, thanks so much!

1 Like

Actually having trouble with the prompt for file action ( most likely user error)

When I go to select an item, all the images are greyed out and I don't get an option to select anything, any idea what this could be?

It works fine for me with JPGs and PNGs. What sort of images are you trying to use it with? Either way, you could always try deleting the public.image text from the "Allowed Types" field so that it accepts all files and see if that solves it.

Hmm, I don't know, every single file is greyed out, no matter the file type. The only things selectable are file folders.

Hmm. Are you on macOS 10.14 Mojave? If you are, you might be running into the accessibility permission problem preventing KM from controlling the Finder, so you might start by following the instructions at that link. If that isn't it, you might try restarting the KM Engine and seeing if that fixes the problem.

As a last ditch resort, you could also use a "For Each file selected in the Finder" action to get the path of the file you want, and disable that action afterwards so it doesn't keep changing the resulting variable every time you run the macro:

image

Are you configuring the Image in a Click at Found Image action?

It looks like you are configuring the folder in a Prompt for File action, which will only accept folders (which is why every file is greyed out).

Ah I misunderstood the use of the prompt for file action, i thought it was a means to select the image in the finder as opposed to typing in the image location in the set variable to text action.

Is there anyway to do this? Typing in the file location manually is a minor inconvenience so it's fine regardless but would definitely prefer to select the image through the finder if possible.

I just tried again and can verify that Prompt for File can absolutely be used to select an image in the Finder and set it to a variable that can be used in Found Image actions, so that's not the issue. But thanks to @peternlewis's observation, I think I've realized what the issue is. When you try the action, are you clicking here:

58%20AM

or here?

59%20AM

The former is what you want when trying the action out separately from running the whole macro. The latter will only let you select a folder for the action to look for images in, so if that's what you've been clicking, that would explain the behavior you're seeing.

Ah, this was the issue but now that it works I've realized I might've miscommunicated what I'm looking for. I didn't want to select a file while the macro is running each time it starts, I just wanted to select an image via the finder in the editor.

Glad we got that mystery solved. It's perfectly understandable that you wouldn't want to choose the image again every time the macro is run, so the simplest way to get around that is probably to just disable the Prompt for File action so that it doesn't run when the macro runs, then re-enable it and use it manually with the Try button when you want to select a new image.

Perfect, worked like a charm, thanks for all your help!

1 Like

Hello!

I tried this macro and for some reason I'm missing the
"File: %variable%image%path" part within the "Move and Click at..."action

Is there any reason I'm not able to see it?

Thanks!

KM version? OS version?

Just downloaded thee macro and I confirm I see all the actions like ggclick's screenshot. Can you share an screenshot?

You can type the text %Variable%ImagePath% in the File field:

image