IfWindowOpen

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
pzelenka
Newbie
Posts: 11
Joined: Mon Nov 25, 2002 9:55 pm
Location: South Dakota

IfWindowOpen

Post by pzelenka » Tue Dec 03, 2002 3:23 pm

I am working with the IfWindowOpen command in an effort to do some error trapping and things aren't working quite right, yet.

My situation is as follows:

I have the process reading a line of text from a file and switching to another screen to place the data into a field. The entry of this data is checked against the the data in an existing record. If the data is on record, the record will be pulled into place and the process continues to make a change. This is really useful for making mass changes to large numbers of records. Not like I'm tellin' y'all anything new.

But....when the data entered from the text file doesn't match any in an existing record, a windows dialog box/window opens with "Warning" in the windows header. In the body of the box/window is the message, "This entry is unavailable", along with an "OK" button.

I would like to detect the Warning dialog box/window and if it appears to enter the data in an error log and to then remove the dialog box and to go on to the next line for entry.

I am testing the script with a text file that has three lines in it. The first and third lines are valid entries, the second is not. When running the script, it will go to conclusion but there is no evidence in the script log that the IfWindowOpen command in functioning properly and there is not an entry in the error log file.

Below is the script and if anyone could spot the reason that the IfWindowOpen is not detecting the open "Warning" window and moving the process to the LetsUpdateErrlog label, I'd be most greatful.

****SCR****

Remark>Read data from text file into MIS
Let>k=1
Label>start
Remark>Enter mnemonoic from text file into MIS User
ReadLn>C:\My Documents\ISJobs\conf change test2.txt,k,line
If>line=##EOF##,finish
Let>WF_TYPE=0
SetFocus>MIS Database*
Send>line
Press Enter
Wait>0.5

Remark>Detect error-unavailable entry
IfWindowOpen>Warning,LetsUpdateErrlog

Remark>Change page make entry file
Wait>0.5
Press ALT
Send>c
Release ALT
Wait>0.1
Send>N
Press F12
Wait>0.5
Press Enter

Remark>Recovery point from error increment "k"
Label>ErrorRecoveryPoint
Let>k=k+1
Goto>start

Remark>Make entry in error log
Label>LetsUpdateErrlog
WriteLn>C:\My Documents\ISJobs\MISCCErrlog.txt,result,%line%
Press Enter
Goto>ErrorRecoveryPoint

Label>finish



Here is the script to date:

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

Post by Marcus Tettmar » Tue Dec 03, 2002 4:45 pm

Hi,

The window probably just isn't open yet. The IfWindowOpen could be occuring too soon in the script and the window is not yet open.

You might want to increase the wait time before the IfWindowOpen command, or use a WaitWindowOpen with a timeout. If it times out the warning window didn't appear. If it didn't time out, the warning window has popped up.

Problem is this will slow the script slightly - you'd need to come up with a suitable time within which the warning window appears - when it does appear.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Ernest

Post by Ernest » Tue Dec 03, 2002 4:48 pm

Hi pzelenka,
looks like the well known window issue :)

I assume you've tried to detect the title with something like this:

Code: Select all

//force the popup to appear, start this & click the popup (not it's button:-)to get the focus back to it while detecting
Wait>5
GetActiveWindow>window,x,y
MessageModal>title: %window%%CRLF%xpos: %x%%CRLF%ypos: %y%
maybe timing is the issue (the 0.5 sec between the line input and the IfWindowOpen>). Checkout 3,2,1 sec ...

if that sucks, and the popup warning always appears at the same coordinates, use the WaitPixelColor command:

Code: Select all

//sample check for a "black"pixel at x=652 y=355 for at least 3 sec.
WPC>0,652,355,3
If>WPC_RESULT=TRUE,LetsUpdateErrlog

//Change page make entry file
.
.
.

Label>LetsUpdateErrlog
//close the warning popup
Press Enter
WLN>"C:\My Documents\ISJobs\MISCCErrlog.txt",result,%line%
Ernest

BTW: check if you've to use ("...") to set a path which contains spaces e.g. "..\My Documents\.."

pzelenka
Newbie
Posts: 11
Joined: Mon Nov 25, 2002 9:55 pm
Location: South Dakota

Post by pzelenka » Tue Dec 03, 2002 8:29 pm

Well, I spend my coffee time and lunch time playin' with this script and it seems to do what I want now. The window is identified and the error log is created properly. Lastly and not least of all, the changed were made as desired for a grouping of 25 test data entries.

Now to run the 820 live data entries trough the thing.....

Here is what I ended up with for a script:

Remark>Read data from text file into MIS
Let>k=1
Label>start
Remark>Enter mnemonoic from text file into MIS User
ReadLn>C:\My Documents\confchange.txt,k,line
If>line=##EOF##,finish
Let>WF_TYPE=0
SetFocus>MIS Database*
Wait>0.5
Send>line
Press Enter

Remark>Detect error-unavailable entry
Let>GAW_TYPE=1
Wait>1.0
GAW>window_title,X,Y
If>window_title=Warning,LetsUpdateErrlog

Let>WF_TYPE=0
SetFocus>MIS Database*

Remark>Change page make entry file
Wait>0.5
Press ALT
Send>c
Release ALT
Wait>0.1
Send>N
Press F12
Wait>0.5
Press Enter

Remark>Recovery point from error increment "k"
Label>ErrorRecoveryPoint
Wait>0.1
Let>k=k+1
Goto>start

Remark>Make entry in error log
Label>LetsUpdateErrlog
WriteLn>C:\My Documents\MISCCErrLog.txt,result,%line%
Wait>1
Press Enter
SetFocus>MIS Database*
Remark>Clear entry error from page1-field1
Wait>1.0
Press Del
Goto>ErrorRecoveryPoint

Label>finish
Let>MSG_STAYONTOP=1
Message>Update Finished

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