Jitbit Macro Recorder - IF Image statement, why it is not waiting until the image appears?

5.2k Views Asked by At

I am using Jitbit MacroRecorder and it is a really helpful tool. The problem is this: By using the IF image found feature, I want the program to execute 2 sequential commands as soon as the image I selected on my screen appears. However, the program is putting too much load on the CPU by running thousands of times until the IF statement is true. What I want is for the program to WAIT until the image in the IF image found statement appears on the screen, that is, not to run thousands of times.

My simple code

2

There are 2 best solutions below

0
BobD59 On

The only way for the program to know when the image appears is to continuously "scan" the screen until it sees it. You may be able to use the image NOT found feature inside a loop with a delay. You would look for the image, and if not found, delay a second, and then look for it again. The tradeoff is you will have that delay in there which will keep your program from running the following commands immediately.

0
Beridok On

Use Labels and "Go To" to loop on checking condition. Creating something like "while" loop. As per official documentation from developers: https://www.jitbit.com/docs/macrorecorder/macro-if-statements.htm

"Waiting For" something using IF-statements

Macro Recorder can be used to "wait for" something using the built-in IF statements. With this feature, for instance, you can make Macro Recorder "watch" the hard disk, and perform some actions, when a particular file appears in a folder. Another example: with the following script Macro Recorder will wait until some particular text appears in the clipboard, and then exit:

LABEL : start
IF CLIPBOARD EQUALS : test
GOTO : end
ENDIF
DELAY : 5000
GOTO : start
LABEL : end

As you can see, this macro checks the clipboard every 5 seconds, and if the text in the clipboard is "test", the macro exits.

IMPORTANT: after inserting an IF-statement remember to insert a corresponding ENDIF