I like the found-image-action within KM but is it possible to put it the other way round and define an on screen area and tell KM to perform an action if a specific image is within this area.
A little more detailed. Within Media Composer I would like to ‚solo‘ a track with a hotkey. I have a fixed workspace so by default I can use the mouse-action but depending on whether there’s a master clip, a sequence or nothing in the source monitor the position of the ’s’-button changes horizontally (See examples).
My goal is to set up an if/else-action and tell KM if the image is found within that area perform a click otherwise move the mouse to the other possible positions.
The if/else action has the ability to search an area of the screen for an image and act accordingly. Something like the action below should work for you.
Thanks a lot Chris!
I'm almost successful with this macro.
When there is a master clip in the source monitor (A) or no source (B) in the source monitor it works fine.
Only the third case when there is a sequence clip in the source monitor (C) KM clicks at the first case position (A).
Any ideas? Solo A1.kmmacros (14.8 KB)
Gotcha, you basically need to click at one of three found images. Ok there’s multiple ways of doing that. You could use a separate If/else action for each image, and if “image a” (or “image b”, “image c” etc.) is found, then click relative to it, else do nothing. I have used this method quite a bit in the past to look for multiple images and it works quite well.
However, there is another way I have seen mentioned on the forum that should also work. Below is a demo macro (you need to fill in the images, and adjust the numbers in the click mouse action) that might work as well, and is a little more concise. DISCLAIMER: I have never tried this method because I got away from using found image actions awhile ago, but I’ve always wanted to try it haha.
Hey Chris,
Thanks for the effort. Very interesting. I'm learning something.
Sorry for the dumb question but in your macro what does KM actually do? I define three different images to be found but on which image does KM eventually click?
I don't get it.
In terms of my case I guess you misunderstood me.
'you basically need to click at one of three found images' is not really my situation.
It's rather that KM should look for a particular image in three possible positions.
I thought I'm on a good way with the If/else-actions in my macro but somehow it doesnt work (see my first reply for details)
Again thanks and have a nice evening,
Simon
In my version, it looks for three different images and clicks on whichever one it finds. That’s what I thought you needed.
However, if all you need is to click on a single image that doesn’t change, but whose location does change, then that is even easier. Just setup a click on found image and set it to in area or in front window etc. This way KM will look for that image in whatever location(s) you specify.
Let me know if that doesn’t make sense and I can give you an example this evening or weekend!
So I came up with this macro and I'm almost there. It works for the Case '2' and '3' right but not for Case '1' (In this case it performs the '2'-condition, meaning mouse moves to the Case-'2'-scenario).
It's very difficult to debug a macro that relies on found images when you don't have the program, don't have the same size screen, have no coordinate references on the images, etc.
But I think your use of Global variables is masking the real problem. Globals persist across runs -- if Solo Location is set to 2 in the first execution and then you run the macro when there's no source clip in the source monitor but the image detection fails, Solo Location will still be set to 2 and the wrong thing will happen.
Also, you only need one "Switch/Case" action -- you test the condition then do this or this or this depending on the result. And it's good to have an "otherwise" to handle all other cases:
I've used the same Global variable as you so you can easily see what's happening but, again, you should change to using a Local (unless you need the value to persist, for example so you can use it in another macro). If it is a Local it won't have a value if all three image detects fail and you'll get an obvious indication via the "Switch/Case" action's "otherwise" dialog.
Hey Nige and Chris,
Thanks so much! It works (almost) perfectly!
From time to time the mouse click is not always in the right area (especially right after the cases change)
but definitely a situation I can work with.
Kind regards,
Simon