The principal is simple. Let's say you wish to run Macro A when a certain image is visible on screen. You'd simply write a second macro, which we'll call Trigger, which looks for the image.
Then all you need do to is go into custom event triggers and tell Macro A to use Trigger.
We have to follow a few simple rules, so here's an example.
------------
I used the Image Capture Tool (found in the script editor, under Tools) to grab one of the buttons in Audacity. If my trigger sees that button, my macro triggers.
Macro saved as Trigger.scp:
Code: Select all
SRT>Trigger
FindImagePos>c:\audacity.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
Let>MACRO_RESULT=TRUE
Else
Let>MACRO_RESULT=FALSE
Endif
END>Trigger
SRT>Reset
FindImagePos>c:\audacity.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
Let>MACRO_RESULT=FALSE
Else
Let>MACRO_RESULT=TRUE
Endif
END>Reset
Code: Select all
messagemodal>I see it!
Open Macro A and go to the Trigger tab. Under "trigger type" select "Custom Event (Script)"
Using the browse button, browse to your script directory and select "Trigger.scp". Click "open", and save Macro A.
The next time your image is visible on screen, Macro A will burst into life!