I'm new to windows scripting so this is my first attempt...
The following code works perfectly when I step through it, but when I try to run the script, it will not wait long enough for the FIP command to find the image. It doesn't matter how many seconds I put in the Wait> command after the FIP, the script keeps on trying to execute the commands that follow. As a result, it processes data that I am trying to read in and write to the app too fast.... which gives me errors. I've also tried putting in wait commands at various points AFTER the IF statement....to no avail. What am I missing?
By the way....this app that I'm working with is rather convoluted. The various message windows that popup have the same title as the main window and I cannot distinguish between them. Neither do the popup windows appear in the View System Windows tool. Therefore I am trying to identify them using images.
Any suggestions?
Repeat>r
// Get the acctno for this row
DDERequest>Excel,Infilename,R%r%C1,acctno,13
// Remove the CRLF that Excel adds
StringReplace>acctno,CRLF,,acctno
// Press people icon
MouseMove>24,55
LClick
Wait>1
SetFocus>Account*
Press Tab * 4
Press Up * 4
Press Down * 2
MouseMove>280,132
Wait>0.5
LClick
// Paste account number in CCS window
SetFocus>CCS Desktop*
Send>%acctno%
Wait>0.05
MouseMove>16,158
LClick
// THIS CODE FINDS THE NO DATA BOX IF PRESENT:
Let>sX=0
Let>sY=0
Let>Xpos=0
Let>Ypos=0
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,c:\scripts\images\screen.bmp
FindImagePos>c:\scripts\images\NoData.bmp,c:\scripts\images\screen.bmp,0,1,Xpos,Ypos,NumFound
wait>5
// THIS CODE PRESSES THE OK BUTTON TO CLOSE THE NODATA WINDOW:
if>NumFound>0
WriteLn>Outfile1,outresult,%acctno%
Let>ycoord=Ypos_0+35
MouseMove>Xpos_0,ycoord
Wait>0.5
LClick
MouseMove>620,83
LClick
else
MouseMove>190,284
LDblClick
Wait>1
WriteLn>Outfile2,outresult,%acctno%
MouseMove>620,83
LClick
LClick
ENDIF
// Get next account number
Let>r=r+1
Wait>0.05
Until>r=6
Script Won't Wait Long Enough
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Should you not be using WaitScreenImage? From what you are saying NoData.bmp is always found in screen.bmp. Waiting 5 seconds after the FIP command is not going to make a jot of difference on its outcome.
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?
OK...tried every wait command there is....in every position I could reasonably think to put it. Nothing works. Here's what it appears is happening. When I step thru the script in debug mode, it finds the NoData msg bmp and executes the proper code in the IF cmd. However, when I run the script, it apparently does NOT find the NoData msg bmp (which IS present) and it tries to execute the code in the ELSE portion of the script and beyond. I know this because I can follow the mouse moves where it is looping back through on the second loop.
I can't use the WaitScreenImage cmd because the NoData bmp does not always appear. It only pops up if there is an error in the account number.
This app typically uses these popup messages for all sorts of errors.... and I CANNOT find this window in the View System Windows tool.
I can't use the WaitScreenImage cmd because the NoData bmp does not always appear. It only pops up if there is an error in the account number.
This app typically uses these popup messages for all sorts of errors.... and I CANNOT find this window in the View System Windows tool.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Sounds like you need a Wait *before* the FindImagePos command. When you run the script the FIP command occurs too quickly/early. So the image is never there. When you debug you slow it down. So you must be looking for the image too quickly.
Your code is doing an LClick which presumably results in a change on the screen. You then use the FindImagePos command to check the outcome. But you are not allowing time for the LClick to take effect.
Either use a static Wait time, before the FindImagePos command, or find a better way to know when to look for the image.
What happens after you do the LClick? Is there something predictable that you can look for? Maybe you need a WaitScreenImage, or WaitWindowOpen BEFORE you then use the FindImagePos command to see whether or not the NoData image is present.
Hope this makes sense.
Your code is doing an LClick which presumably results in a change on the screen. You then use the FindImagePos command to check the outcome. But you are not allowing time for the LClick to take effect.
Either use a static Wait time, before the FindImagePos command, or find a better way to know when to look for the image.
What happens after you do the LClick? Is there something predictable that you can look for? Maybe you need a WaitScreenImage, or WaitWindowOpen BEFORE you then use the FindImagePos command to see whether or not the NoData image is present.
Hope this makes sense.
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?