IfWindowOpen always return true

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
cgaston
Junior Coder
Posts: 24
Joined: Sat Jan 22, 2005 11:52 am
Location: Ottawa, Canada

IfWindowOpen always return true

Post by cgaston » Tue Jan 25, 2005 3:16 am

I do not want the OR Manager application to be running when I launch a macro. So, i used the following code:

IfWindowOpen>OR Manager*,STOP,CONTINUE
Label>STOP
Show>CloseOR,Close
GoTo>End
Label>CONTINUE
...
...

Altough OR Manager is not running, The dialog "CloseOR" is getting displayed all the times.

Five lines of code, and I cannot see what is wrong. That drives me crazy!

Gaston.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jan 25, 2005 3:51 am

Remove the line for SHOW>
Show> is used to display Dialog Windows created with Macro Scheduler.

You may want to use:

Code: Select all

WindowAction>3,OR Manager 
to close that window, but it might be safer to set focus to the window and exit the program normally instead.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

cgaston
Junior Coder
Posts: 24
Joined: Sat Jan 22, 2005 11:52 am
Location: Ottawa, Canada

Post by cgaston » Tue Jan 25, 2005 4:40 pm

Hi Bob,

I use the SHOW> command to display a dialog box that will say "You must exit OR Manager before running this Macro.", with two buttons:

1- Cancel - Terminate the script
2- Continue - Assume the user have terminated OR Manager, then Continue

I could have used a MessageModal as well, but that still do not explain why the damn IfWindowOpen command return TRUE.

Thank you,

Gaston.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jan 25, 2005 4:54 pm

Oops, I misread your message.

I am unable to duplicate problem. Never show Dialog. Log file does not show script going to STOP.

Can't see how dialog would impact, but can you provide Dialog>CloseOR code also?

Maybe entire script should be provided in case other sections are causing this.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

cgaston
Junior Coder
Posts: 24
Joined: Sat Jan 22, 2005 11:52 am
Location: Ottawa, Canada

Post by cgaston » Tue Jan 25, 2005 9:56 pm

I have another clue:

If I replace IfWindowOpen>OR Manager*,
for IfWindowOpen>vvhjviava*,
it works fine.

So, that means that MS is really "seeing" a window named "OR Manager...".

That window is hidden to me. Is there a way to determine where it is coming from?

The complete code is as follows:

Dialog>FermerOR
Caption=OR Manager est Ouvert!
Top=174
Width=384
Left=141
Height=191
Label=Vous avez déjà une session OR Manager d'ouverte.%CRLF%%CRLF%Vous devez fermer OR Manager avant de continuer.,64,32
Button=Continuer,88,104,75,25,1
Button=Annuler,224,104,75,25,2
EndDialog>FermerOR

IfWindowOpen>OR Manager*,STOP,CONTINUE
Label>STOP
SetFocus>OR Manager*
Show>FermerOR,Fermer
If>Fermer=2
GoTo>Fin
EndIf

Label>CONTINUE

Gaston.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jan 25, 2005 10:22 pm

Have not really read your last message totally, am on the run, but now suspect that because OR is a boolean operator that it may be causing the problem.

Try making the window name a variable and using that variable in the IfWindowOpen> command to eliminate using OR anywhere other than defining the variable.......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Jan 25, 2005 11:13 pm

I don't know if there is something special about the way that program has to be closed, but if not you could just PSKILL it http://www.sysinternals.com/ntw2k/freeware/pskill.shtml In my experience PSKILL doesn't cause an error if the program isn't open so you can just routinely call it from the script.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jan 26, 2005 12:08 am

I tried the full script that you provided and I never see the Dialog. I looked at a log script and the Show> command is never called.

Here is my log:
1/25/2005 18:41:33:890 - Started Macro : test
1/25/2005 18:41:33:940 - Dialog>FermerOR
1/25/2005 18:41:34:000 -
1/25/2005 18:41:34:000 - IfWindowOpen>OR Manager*,STOP,CONTINUE
1/25/2005 18:41:34:000 - Goto>End (I added this under the CONTINUE label).
1/25/2005 18:41:34:050 - Finished Macro : test
=========================

Your original problem was:
Altough OR Manager is not running, The dialog "CloseOR" is getting displayed all the times.
Am I missing something? I have still not seen the Dialog appear.

-----------------------------
1. I just tried to Single Step through the script and got invalid pointer error message on line IfWindowOpen>.
I added Let>LookFor=OR Manager* and modified script to

Code: Select all

Let>LookFor=OR Manager*
IfWindowOpen>%LookFor%,STOP,CONTINUE
and error message went away. This seems to confirm my earlier suspicion that OR is being interpreted as an operator. I suspect the error is allowing the script to continue vs. branching.

2. I also found that there was a trailing space after "Label>CONTINUE ". I had to remove the trailing space to go to CONTINUE properly.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

cgaston
Junior Coder
Posts: 24
Joined: Sat Jan 22, 2005 11:52 am
Location: Ottawa, Canada

Post by cgaston » Wed Jan 26, 2005 2:16 am

Hi Bob,

Thank you for your patience.

The idea to use the LookFor variable did not change anything to my problem.

However, I think that your suspicion that OR is being interpreted as an operator still deserve the grand prize.

The full window title is "OR Manager - Live Database"

So, I changed my IfWindowOpen>OR Manager
for IfWindowOpen>Live Database and then this little thing got happy
as ever!

I am puzzled about the fact that you did not experienced the problem. It could be the environment. I am running MS Pro version 7.3.06 under Windows 2000.

In any case, you've been of great help. Thanks again.

Gaston.

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