Script Error - Window Missing in OnEvent subroutine

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
KariOlson
Newbie
Posts: 3
Joined: Mon Aug 27, 2007 5:19 pm

Script Error - Window Missing in OnEvent subroutine

Post by KariOlson » Tue Sep 04, 2007 12:59 pm

Sometimes, when I run the script that includes the following snippet, I get an error message from Macro Scheduler that the window is missing. I don't understand how it can be missing since, I use OnEvent to look for the window and only make one key press alt-o (which closes the window).

This portion of the script is used to wait for a process complete window or a popup error message (Update Material Handling Device Quanitity). If the error message pops up, it is OK'd and we continue to wait for the complete window. The macroscheduler error message is that the error popup is not there.

Code: Select all

//Global settings
Let>WW_TIMEOUT=180
Let>VAREXPLICIT=1
Let>WF_TYPE=2
CapsOff

[...]

WaitWindowOpen>FactoryFLOW Calculation Progress

//what if MH Quantities are wrong?
OnEvent>WINDOW_OPEN,Update Material Handling Device Quantity,2,QUANTITY_ERROR

Label>LOOKING_FOR_QUANTITY_ERROR
Wait>1
IfWindowOpen>FactoryFLOW
   Goto>CALCULATION_COMPLETE
Endif
Goto>LOOKING_FOR_QUANTITY_ERROR

SRT>QUANTITY_ERROR
SetFocus>Update Material Handling Device Quantity
WaitReady>0
//OK
Press ALT
send>o
Release ALT
END>QUANTITY_ERROR

//Calculation Complete
Label>CALCULATION_COMPLETE
SetFocus>FactoryFLOW
WaitReady>0
Press Enter

[...]
I suspect this is the release alt command which could happen right after the window closes. There is no other key combination that works (enter, alt then o, etc). Is there some way to turn off this error message popping up or other sugggestions for modifying this code?

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

Post by Marcus Tettmar » Tue Sep 04, 2007 1:18 pm

Hi,

Have you debugged this to be sure this error is occurring in the QUANTITY_ERROR subroutine?

If so, it's possible that the window no longer exists by the time the subroutine is executed. Try changing the subroutine to:

Code: Select all

SRT>QUANTITY_ERROR
  Let>WF_TYPE=2
  IfWindowOpen>Update Material Handling Device Quantity
    SetFocus>Update Material Handling Device Quantity
    WaitReady>0
    //OK
    Press ALT
    send>o
    Release ALT
  Endif
END>QUANTITY_ERROR
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

KariOlson
Newbie
Posts: 3
Joined: Mon Aug 27, 2007 5:19 pm

Debugging

Post by KariOlson » Tue Sep 04, 2007 2:17 pm

Please excuse some of the confusion, I have multiple copies and didn't check that the one I copied from was the latest, I have in fact added a check if the window is open in the subroutine (although it should be called on event window open and should be open). I have also verified that this window title is not anywhere else in the script. The window cannot be closed without macroscheduler or human intervention (in this case no human intervention, its running on a PC in a locked room and I am remotely monitoring it).

Code: Select all

//Global settings
Let>WW_TIMEOUT=180
Let>VAREXPLICIT=1
Let>WF_TYPE=2
CapsOff

[...]
WaitWindowOpen>FactoryFLOW Calculation Progress

//what if MH Quantities are wrong?
OnEvent>WINDOW_OPEN,Update Material Handling Device Quantity,2,QUANTITY_ERROR

Label>LOOKING_FOR_QUANTITY_ERROR
Wait>1
IfWindowOpen>FactoryFLOW
   Goto>CALCULATION_COMPLETE
Endif
Goto>LOOKING_FOR_QUANTITY_ERRORSRT>QUANTITY_ERROR

SRT>QUANTITY_ERROR
IfWindowOpen>Update Material Handling Device Quantity
   SetFocus>Update Material Handling Device Quantity
   Wait Ready>0
   //OK
   Press ALT
   send>o
   Release ALT
Endif
END>QUANTITY_ERROR 

//Calculation Complete
Label>CALCULATION_COMPLETE
SetFocus>FactoryFLOW
WaitReady>0
Press Enter

[...]


I will try adding the WF_Type=2 inside the subroutine (this is already set in the body of the code).

Is there any chance this is related to the subroutine being embedded in the flow of the program?

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

Post by Marcus Tettmar » Tue Sep 04, 2007 2:24 pm

Are you sure the warning is generated in the subroutine?

As you say, it's hard to see how that code could generate such a warning, since the SetFocus would never execute unless the window was present.

Therefore I wonder if we're looking at the right section of code - could we be barking up the wrong tree here? Have you debugged it and identified the exact section of code that generates this error?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Post by JRL » Tue Sep 04, 2007 3:11 pm

As you say, it's hard to see how that code could generate such a warning...
I disagree. Its easy to see how such a warning could be triggered. OnEvent fires off like a machine gun. You could easily send a close window command and have OnEvent fire off again before the window
closes. I'd try putting WaitWindowClosed at the end of the "QUANTITY_ERROR" subroutine.

Code: Select all

SRT>QUANTITY_ERROR
IfWindowOpen>Update Material Handling Device Quantity
   SetFocus>Update Material Handling Device Quantity
   Wait Ready>0
   //OK
   Press ALT
   send>o
   Release ALT
   WaitWindowClosed>Update Material Handling Device Quantity
Endif
END>QUANTITY_ERROR
Just a thought,
Dick

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

Post by Marcus Tettmar » Tue Sep 04, 2007 3:17 pm

Good point. You're right - we must make sure the window has closed before we return flow to the script or the onevent could immediately fire again. I missed that.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

KariOlson
Newbie
Posts: 3
Joined: Mon Aug 27, 2007 5:19 pm

Thanks - good idea

Post by KariOlson » Tue Sep 04, 2007 4:59 pm

Great idea. I'll add the wait window closed.

So far I haven't been able to replicate this error today although it drove me nuts on Friday - go figure. Thus, I can't be sure the subroutine is causing the macrosheduler error, but the window title is unique to that block of statements.

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