Why doesn't my IfWindowOpen command work?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
RixsterFL

Why doesn't my IfWindowOpen command work?

Post by RixsterFL » Thu Sep 23, 2004 4:27 pm

I have tested the below script without the IF command and the process works as I was hoping. Now I want to ensure that I do not open a duplicate window, however when debugging I get an error. "The 'true' label can not be found.

What am I missing or doing wrong? Any help would be greatly appreciated.

Rick

IfWindowOpen>CoverLetter - Microsoft Word,true
ExecuteFile>D:\My Documents\CoverLetter.doc
WaitWindowOpen>CoverLetter - Microsoft Word
Label>true
SetFocus>CoverLetter - Microsoft Word
Press CTRL
Send Character/Text>ac
Release CTRL
Run Program>notepad.exe
WaitWindowOpen>Untitled - Notepad
SetFocus>Untitled - Notepad
Press CTRL
Send Character/Text>V
Release CTRL

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Fri Sep 24, 2004 1:04 am

Hi Rick,

Please try:

1. IfWindowOpen>Microsoft Word*,true
2. Make sure no trailing space(s)

Happy scripting.

Rixster

Thank You!

Post by Rixster » Sat Sep 25, 2004 7:31 pm

You were right on the money... It seems that I had a space after the lable's name.

Thanks again for the swift reply.

Rick

Toastie
Newbie
Posts: 2
Joined: Fri Mar 11, 2005 11:14 pm
Location: IL

Similar issue

Post by Toastie » Fri Mar 11, 2005 11:30 pm

I am new to MS, but have a fairly good understanding of basic scripting (I think). No matter what I do, my IfWindowOpen statement always runs as if the statement was true. What am I doing wrong? Here's a snipit of code:

Press Enter
Wait>2.00
Let>WF_TYPE=2
IfWindowOpen>KCX\Manager,NoData
Label>Data
GoSub>PrintReport
GoSub>CloseReport
Goto>Return Report
Label>NoData
GoSub>NoDataWindow
Goto>Return Report
Label>Return Report
.
////Subroutines below////
.
SRT>CloseReport
Press CTRL
Wait>0.10
Press F4
Wait>0.10
Release CTRL
Wait>0.10
MouseMove>238,57
End>CloseReport
.
SRT>NoDataWindow
Wait>0.10
Press Enter
WaitWindowOpen>xStore Manager 2.72 - [Work With Reports]
MoveWindow>xStore Manager 2.72 - [Work With Reports],-4,-4
ResizeWindow>xStore Manager 2.72 - [Work With Reports],1032,748
Wait>0.10
End>NoDataWindow
.
SRT>PrintReport
MouseMove>350,224
LClick
Wait>10.00
MouseMove>220,27
LClick
MouseMove>233,72
Wait>2.00
LClick
Wait>5.00
End>PrintReport

I unfortunatly have to use mouse movements and clicks because the program doesn't support keyboard use in all situations.
Any ideas on what I've done wrong?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Mar 12, 2005 1:03 am

There is nothing wrong with your script so if it resolves true then there *IS* a window present on the system at that time matching that string. Has to be. What do you see in Tools/View System Windows?
MJT Net Support
[email protected]

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sat Mar 12, 2005 4:42 am

Hi Toastie,

When pasting your script into Macro Scheduler's Editor, I found that nearly all lines include one or more trailing spaces!

Please switch the value of WF_TYPE to 0, 1, and 2 to see any difference.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Mar 12, 2005 9:01 am

Armsys - the spaces were added when you copied the code from the forum, I can see that the original script had no spaces.
MJT Net Support
[email protected]

Toastie
Newbie
Posts: 2
Joined: Fri Mar 11, 2005 11:14 pm
Location: IL

Post by Toastie » Mon Mar 14, 2005 6:08 pm

support wrote:There is nothing wrong with your script so if it resolves true then there *IS* a window present on the system at that time matching that string. Has to be. What do you see in Tools/View System Windows?
That was it. It turns out that whenever the parent application is running there is a hidden window with that name. I turned my script around so that it looked for the other window (when there is data in the report) and it takes the appropriate action. Here is a snipit of the changed and correct code:


Press Enter
Wait>2.00
Let>WF_TYPE=2
IfWindowOpen>xStore Manager 2.72 - [Form1],DefData,DefNoData
Label>DefData
GoSub>PrintReport
GoSub>CloseReport
Goto>Return Report

Label>DefNoData
GoSub>NoDataWindow
Goto>Return Report

Label>Return Report


Thanks again for the help. :D

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