I'm having a bit of trouble with IF statements...
I wrote a macro that logs in to a particular site, opens a particular project file i have on the site, and sends a message to all of the profiles in my project file.
Every now and then the site cannot send the message. When this happens the site will bring up a big red X sign as notification that the message did not go through. This red X makes the image recognition tool very useful in this instance.
So, what I want to do is get the macro to do the following:
Step 1) Click the Select Message button (using Image Recognition)
Step 2) Select the message I want to send
(If the Red X was to show up it would be after this step so...)
Step 3) Check to see if the Red X shows up
Step 4) IF THE RED X SHOWS UP, THE MACRO SHOULD:
a) Page Down
b) Click the Cancel button (using Image Recognition)
c) Page Up
d) Go Back to Step 1 to try again
Step 5) IF THE RED X DOES NOT SHOW UP THE MACRO SHOULD CONTINUE WITH THE REST OF THE MACRO AS WRITTEN.
Below is the Code that corresponds to Steps 1,2,3 & 5. The code for these steps seems to work fine. The problem comes into play when I try to put in the IF statement that would correspond to Step 4
Code: Select all
Label>Start
WaitScreenImage>%SCRIPT_DIR%\ClearButton.bmp,0
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\All Button (Project Page)_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
'A - CLICK "SELECT MESSAGE" BUTTON
WaitScreenImage>%SCRIPT_DIR%\NoneBlue.bmp,0
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\Send Message_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
'B - WAIT FOR SEND MESSAGE WINDOW TO OPEN
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\SendMessage_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Wait 2.0
'C - OPEN MESSAGE DROP DOWN MENU
WaitScreenImage>%SCRIPT_DIR%\Send Message Window.bmp,0
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\TemplatesSendMessageWindow_1.bmp,SCREEN,0,8,XArr,YArr,NumFound
If>NumFound>0
MouseMove>{%XArr_0%+10},YArr_0
LClick
Endif
Wait 5.0
WaitScreenImage>%SCRIPT_DIR%\None_Template_Dropdown.bmp,0
Wait 5.0
'D - SELECT THE CHICAGO STAFF MESSAGE TEMPLATE
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\Template_A-01_Chicago_Area-Staff_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Wait 2.0
'***THE IF STATEMENT FOR STEP 4 SHOULD GO HERE***
'E- IF RED X IS ON THE SCREEN
IF
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\RED_X.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
'F - PRESS PAGE DOWN
Press Page Down
'G - CLICK CANCEL BUTTON TO CLOSE SELECT MESSAGE WINDOW
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\CANCELBUTTON.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
'H - WAIT UNTIL THE SEND MESSAGE WINDOW GOES AWAY
WaitWindowChanged
'I - PAGE UP
Press Page Up
'J - GO BACK TO "A"
'???I HAVE NO F$%#! CLUE HOW TO CODE THIS BECAUSE I'M ALREADY USING A LABEL/GOTO. HOW DO I EMBED A CONDITIONAL LOOP IN A LOOP?
EndIf
'IF RED X DOES NOT APPEAR ON SCREEN THEN...
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\RED_X.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound=0
MouseMove>XArr_0,YArr_0
LClick
Endif
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\Contact Info_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Wait 2.0
Press Page Down
Wait 1.0
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\TrackingID_2.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Wait 0.2
Send 2000CHI
Wait 0.1
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\Send InMails_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Wait 5.0
Press Home
WaitScreenImage>%SCRIPT_DIR%\Successfully_Sent_Message.bmp,0
Press End
Wait>0.5
Let>FIP_SCANPIXELS=ALL
FindImagePos>%SCRIPT_DIR%\NextPage-SendMessage_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
WaitScreenImage>%SCRIPT_DIR%\All-SendMessage.bmp,0
[color=blue]Goto>Start[/color]
I apologize if this is so long that it's hard to follow. I tried to lay out each step clearly, but if anyone can help with this that would be fantastic.
Thanks!
R.J.