WSI_TIMEOUT issues

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

WSI_TIMEOUT issues

Post by zabros2020 » Fri May 08, 2009 5:47 am

Hi guys,
My first post ever... I'm excited

I am writting a script which extract data from an e-mail and searches for one of my customers. Once the name appears, the mouse moves over the name and clicks to go to the customer info page. the process of locating a customer varies from 2 seconds to about 60 seconds, depending on how our server is going on the day. Sometimes the info in the e-mail is incorrect and there is no customer.

this is what i have so far:

Code: Select all

Let>WSI_TIMEOUT=60
WaitScreenImage>%HomePath%Arrow.bmp,5
if>WSI_TIMEDOUT=TRUE
    Let>ErrMsg=Error message 1
    GoTo>ExitRoutine
EndIf

FindImagePos>%HomePath%Arrow.bmp,SCREEN,5,1,X,Y,NumFound
If>NumFound=0
    Let>ErrMsg= Error message 2
    GoTo>ExitRoutine
EndIf

// Wait for Customer window to display and populate
SetFocus>%CustomerInfo%
GetActiveWindow>%CustomerInfo%,XX,YY
Add>XX,275
Add>YY,193
MouseMove>XX,YY
LClick

// Wait for up to 20 seconds for Information screen to display
Let>WSI_TIMEOUT=20
WaitScreenImage>%HomePath%customer_info_loaded.bmp,5

//Look for the customer found button and click it
FindImagePos>%HomePath%customer_found.bmp,SCREEN,5,1,X,Y,NumFound
If>NumFound=0
    Let>ErrMsg= Error message 3
    GoTo>BailOut
EndIf

//Rest of script
The above code is the original. I have created an e-mail an invalid customer number, so the idea is that i search for it for 60 and end up with Error message 1.

However, when i run it. I get Error message 2, after less than 60 seconds which means it is finding Arrow.bmp (which i can assure you is not on the screen anywhere - or anythign remotely similar)

I then attempted to change WSI_TIMEOUT from 60 to 5:
Error message 1 appears

If i leave WSI_TIMEOUT at 10 but change WaitScreenImage>%HomePath%Arrow.bmp,5 to WaitScreenImage>%HomePath%Arrow.bmp,2
Error 1 appears.

If i leave WaitScreenImage>%HomePath%Arrow.bmp,2 and change WSI_TIMEOUT to 15
Error message 2 appears

Please help me, why is does changing how long my script waits for a particular image to display affecting it finding the image or not.

Thank you very much in advance guys, this forum rocks!
It has solved all my other problems

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun May 10, 2009 2:37 am

You need to define the variable "HomePath".

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Also a problem waiting for CustomerIfo window.

Post by gdyvig » Sun May 10, 2009 6:15 am

There are also problems in this section:

Code: Select all

// Wait for Customer window to display and populate
SetFocus>%CustomerInfo%
GetActiveWindow>%CustomerInfo%,XX,YY
Add>XX,275
Add>YY,193
MouseMove>XX,YY
LClick
You need to wait for the window to display before you can SetFocus on it. Is "CustomerInfo" it's actual title, or is that a variable? Let's say "Customer Information" is the actual title. Your code should be:

Code: Select all

//Wait for visible windows only
Let>WF_TYPE=2
Let>WW_TIMEOUT=20
WaitWindowOpen,Customer Information
If>WW_RESULT=FALSE
   //Add code for graceful exit
   Exit>
endif
//SetFocus will cause script to display error if window is not displayed.
SetFocus>Customer Information
The GetActiveWindow command returns the name of the currently active window. You do not provide the name of the window. The rest of this section of code should be:

Code: Select all

GetActiveWindow>CustomerInfo,XX,YY
//Should return CustomerInfo=Customer Information and the coords.
Add>XX,275
Add>YY,193
MouseMove>XX,YY
LClick

Let us know if it still does not work.

Gale

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

second bite of the cherry

Post by zabros2020 » Mon May 11, 2009 6:24 am

hey guys,
thank you so much for your quick responses. A few things i need to point out.
The variable %HomePath% is predefined to my project folder.
the variable %CustomerInfo% starts out being set to the window name Customer Info, which is why i can setfocus> on it.

Other than that, i have tried the suggestions outlined below, i did find it quite hard to know where they were meant to be modified, because my main issue was that my script never waits the 60 seconds and displas error message 1, eventhough the Arrow.bmp image is Never on screen.

This is what i have now and it is still not working.

Any suggestions?

Code: Select all

Let>WSI_TIMEOUT=60
WaitScreenImage>%HomePath%Arrow.bmp,5
if>WSI_TIMEDOUT=TRUE
    Let>ErrMsg=Error message 1
    GoTo>ExitRoutine
EndIf

WaitReady>1
FindImagePos>%HomePath%Arrow.bmp,SCREEN,5,1,X,Y,NumFound
If>NumFound=0
    Let>ErrMsg= Error message 2
    GoTo>c
EndIf

// Wait for Customer window to display and populate
Let>WF_TYPE=2
Let>WW_TIMEOUT=20
WaitWindowOpen>%CustomerInfo%
If>WW_RESULT=FALSE
    Let>ErrMsg= Error message 3
    GoTo>ExitRoutine
endif
SetFocus>%CustomerInfo%
GetActiveWindow>%CustomerInfo%,XX,YY
Add>XX,275
Add>YY,193
MouseMove>XX,YY
LClick

// Wait for up to 20 seconds for Information screen to display
Let>WSI_TIMEOUT=20
WaitScreenImage>%HomePath%customer_info_loaded.bmp,5

// Look for the Create Activity button and click it
FindImagePos>%HomePath%customer_found.bmp,SCREEN,5,1,X,Y,NumFound
If>NumFound=0
    Let>ErrMsg= Error message 4
    GoTo>ExitRoutine
EndIf
Thanks once again

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon May 11, 2009 10:22 am

Does arrow.bmp contain a lot of background or a lot of common colours?

1. Set FIP_SCANPIXELS to the number of pixels in arrow.bmp (height x width).

2. Inside your If>WSI_TIMEDOUT check insert a ScreenCapture call. Then we can see the screen as seen by the macro. Send me arrow.bmp and the screen capture and I'll be able to see why it thinks it was found.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Placement of labels

Post by gdyvig » Mon May 11, 2009 9:52 pm

Marcus's question about the background implies that your bmp may be too large and contains a lot of non-unique pixels. Image recognition usally does not compare every pixel for performance reasons. If your image contains a lot of non-unique patterns the script may think it found it all over the screen.

Here is a way to find where the script thought the image was found:

Code: Select all

FindImagePos>%HomePath%Arrow.bmp,SCREEN,5,1,X,Y,NumFound
If>NumFound=0
    Let>ErrMsg= Error message 2
    GoTo>c
else
    //move mouse to first image found
    MouseMove>X_0, Y_0
    //Add a wait so you can see where the mouse is pointing
    //Does this look like part of the arrow?
    wait>20
   //Maybe script found lots of images
   MessageModal>Arrow.bmp NumFound:%NumFound%
endif
Marcus's suggestion to increase FIP_SCANPIXELS to the size of your bmp will force the script to check every pixel and prevent a false match. Another way is to make your arrow.bmp smaller - just include the arrowhead. The long arrowshaft may resemble other parts of the screen.

Gale

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts