im a noob :cry: and a beginner at macro scheduler
i want to know how to use the label, IF, and goto commands
first i want the macro to find an image on the screen
IF it finds it, then i want it to continue with the macro....
IF it doesnt find it i need it to do something else.
can anyone help me format this using the label, IF, and goto commands?
thankyou!
any help would immensly be appreciated!
how do u use the label, goto, and if commands?
Moderators: Dorian (MJT support), JRL
Using a script mostly found in the help for FindImagePos>.
Code: Select all
GetScreenRes>X,Y
ScreenCapture>0,0,X,Y,d:\screen.bmp
///assuming "d:\today_button.bmp" is an actual file on your computer.
FindImagePos>d:\today_button.bmp,d:\screen.bmp,0,1,X,Y,NumFound
If>NumFound>0
Goto>ImageFound
Else
Goto>ImageNotFound
Endif
Label>ImageFound
///Do Something
Goto>Next
Label>ImageNotFound
///Do Something Else
Label>Next
From Help for WaitScreenImage>but what if i used waitscreenimage?
*******************************************************
WaitScreenImage>BitmapFile[,Color_Tolerance]
Waits until the image in BitmapFile is found on the screen.
Returns the number of occurrences found on the screen in the WSI_RESULT variable.
Optionally, a Color tolerance value can be specified. The default is 0 (no tolerance). If color_tolerance is zero the pixel colors must match exactly. color_tolerance can be set to a value between 0 and 255. If larger than zero the red, green and blue values of the pixels in bitmap_to_scan are checked to see if they are within the tolerance specified (color value + or - color_tolerance). Smaller values match less and larger values match more.
The system variable WSI_TIMEOUT can be used to set the number of seconds after which this command should timeout. If set to zero (the default) the timeout will not occur and the command will continue indefinitely. If WSI_TIMEOUT is used, WSI_TIMEDOUT will indicate whether or not the command ended successfully. If it timed out WSI_TIMEDOUT will be set to TRUE otherwise, if the image was found within the time out period it will be set to FALSE.
*******************************************************
Therefore, Using WaitScreenImage uses logic something like this:
Code: Select all
Let>WSI_TIMEOUT=5
///assuming "d:\today_button.bmp" is an actual file on your computer.
WaitScreenImage>d:\today_button.bmp
If>WSI_TIMEDOUT=FALSE
Goto>ImageFound
Else
Goto>ImageNotFound
Endif
Label>ImageFound
///Do Something
Goto>Next
Label>ImageNotFound
///Do Something Else
Label>Next
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I could be stating the obvious but you do not need to use Goto/Label. My preference is as follows:
Code: Select all
Let>WSI_TIMEOUT=5
///assuming "d:\today_button.bmp" is an actual file on your computer.
WaitScreenImage>d:\today_button.bmp
If>WSI_TIMEDOUT=FALSE
//Image Found - do something
MessageModal>Found It!
Else
//Image not found - do something else
MessageModal>Not Found!
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
I run the following code:
If imageNeedle exists then the script tells me "Found it!" but if imageNeedle is set to "\\homer\this_file_does_not_exist.bmp" then it tells me "Found it!" too. What's wrong with it?
Code: Select all
Let>WSI_TIMEOUT=5
Let>imageNeedle={"\\homer\existent_file.bmp"}
WaitScreenImage>%imageNeedle%,0
If>WSI_TIMEDOUT=FALSE
MessageModal>Found It!
Else
MessageModal>Not Found!
Endif