Hi,
I am radically trying to optimise our macros. On average how many times faster are If Statements of Variables on KM compared to reading (match) screen image conditions?
e.g. i use a (if) screen image condition to something or i use a (if) variable condition to do something.
which one is faster and how fast is it compared to the other?
Although Keyboard Maestro's image search is very fast, it can't compare to a simple IF test. Like UI Scripting, using a screen image condition should be a last resort, only if nothing else works.
Compared to IF or SWITCH statements/Actions, using found image is:
- Much slower
- Less reliable
1 Like
While finding images on the screen takes magnitudes of time longer than “IF” statements, it’s pretty darn fast in human perception terms. The real speed issue comes in to play when you have to do something in a loop, over and over again.
I have a macro that walks through each frame of a video clip, in Final Cut. It’s the type of thing I start, then walk away from and come back later when it’s done. I have to tell it the number of frames to process, because there’s no way for KM to know when it was at the end of the clip.
So I thought I’d get KM to watch the frame counter, and stop when the frame counter quit advancing.
It really slowed down this macro, since it was doing hundreds of frames at a time. HOWEVER, I did discover that if I limited the area that KM searched the screen for the frame counter, it made a significant difference.
In the long run, though, for other unrelated reasons, I quit using this method.
Bottom line is this: If you’re doing something hundreds or even dozens of times in a loop, the speed difference can be dramatic.
Sheesh, after reading what I just typed, I have no idea if it’s helpful or not. But I’ll post it anyway, just in case…
Thank you. Yes we have a lot of loops with if statements and the macro takes 2 seconds and loops many times. This is why I am trying to find another way of doing the actions without using the screen image conditions
thanks, I will try to use if statements based upon text variables instead
Yeah, I figured that was the case. I just wanted to be sure.