Hi,
I am using this application. It has the name "CubeCom" as its title of the application window.
When there is this "out of resources" error. An error diag with title "Phase 2 Cube HCI"
I tried to write a script to restart the application when the "out of resources" error appears using the onEvent command.
I tried using it to wait for the "Phase 2 Cube HCI" window to pop up (onEvent). But once I start the script, the onEvent is trigger.
After troubleshooting, I found that using "CubeCom" or "Phase 2 Cube HCI" will point to the same main application window.
How can I write the command so that the onEvent is triggered only when the error occurs?
Thanks!
OnEvent: Wait for specific window.
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
// Sample Script
OnEvent>WINDOW_OPEN,Phase 2 Cube HCI,2,ErrorDetect
Let>counter=0
Label>Start
Msg>counter
Wait>1
Add>counter,1
Goto>Start
SRT>ErrorDetect
Msg>Error detected!!!
Wait>1
END>ErrorDetect
//Once I start the script, the "Error detected!!!" msg is seen
//I tried to troubleshoot using the following script
setFocus>Phase 2 Cube HCI
//Make the application as the active window
setFocus>CubeCom
//Make the application as the active window
//Both of the setFocus command is tested separately but produces the same result of making the same Application "CubeCom" as the active window
OnEvent>WINDOW_OPEN,Phase 2 Cube HCI,2,ErrorDetect
Let>counter=0
Label>Start
Msg>counter
Wait>1
Add>counter,1
Goto>Start
SRT>ErrorDetect
Msg>Error detected!!!
Wait>1
END>ErrorDetect
//Once I start the script, the "Error detected!!!" msg is seen
//I tried to troubleshoot using the following script
setFocus>Phase 2 Cube HCI
//Make the application as the active window
setFocus>CubeCom
//Make the application as the active window
//Both of the setFocus command is tested separately but produces the same result of making the same Application "CubeCom" as the active window
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
The programming that you have will show an "error" message when the window is opened. If the window is already open when you start the script perhaps that is firing the event?
You explained that you tried to troubleshoot by setting focus to the window, which indicates that you must think it is already open before the script is run.
Have you tried closing the window, starting the script, and then opening the window to see if no message comes up until you open the Phase 2 window after the script has started?
You explained that you tried to troubleshoot by setting focus to the window, which indicates that you must think it is already open before the script is run.
Have you tried closing the window, starting the script, and then opening the window to see if no message comes up until you open the Phase 2 window after the script has started?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Hi,
Sorry for the bit of confusion here. I am actually doing some software testing.
I have this error that I want to intercept to trigger, while running a script of automated test for the program "CubeCom".
The error will have a pop-up dialog with the window_title of "Phase 2 Cube HCI" but the problem is Both "CubeCom" and "Phase 2 Cube HCI" points to the application "CubeCom".
The hard part is I am trying to use the
OnEvent>WINDOW_OPEN,Phase 2 Cube HCI,2,ErrorDetect
to detect the error and do.... in the subrountine and Once the script starts, the onEvent is triggered cos "CubeCom" is opened
Is there any way for OnEvent> to respond to the error pop up only?
Another thing to note.
The "View System Window" shows the error diag as:
XXXXXXX - #32770 "Phase 2 Cube HCI"
What does the #32770 stands for?...normally, it is the Tform stuffs
Thanks a lot!!!
Sorry for the bit of confusion here. I am actually doing some software testing.
I have this error that I want to intercept to trigger, while running a script of automated test for the program "CubeCom".
The error will have a pop-up dialog with the window_title of "Phase 2 Cube HCI" but the problem is Both "CubeCom" and "Phase 2 Cube HCI" points to the application "CubeCom".
The hard part is I am trying to use the
OnEvent>WINDOW_OPEN,Phase 2 Cube HCI,2,ErrorDetect
to detect the error and do.... in the subrountine and Once the script starts, the onEvent is triggered cos "CubeCom" is opened
Is there any way for OnEvent> to respond to the error pop up only?
Another thing to note.
The "View System Window" shows the error diag as:
XXXXXXX - #32770 "Phase 2 Cube HCI"
What does the #32770 stands for?...normally, it is the Tform stuffs
Thanks a lot!!!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I can't see why the onevent function will be picking up the main window - you have provided a very specific window title. The only reason I can think of is if the window is actually always open when the main app is running. Perhaps hidden in some way. Then again you have wf_type set to 2 so if it is invisible this shouldn't be an issue. It must appear somewhere. Can you see it in View System Windows when the main app is running?
#32770 is the class name. Just like TForm is a class name. #32770 is the class name used by many system dialogs. Don't ask me why Microsoft chose that as the class name. They are at liberty to call a class what they like. Fred or Sally could be equally valid class names.
#32770 is the class name. Just like TForm is a class name. #32770 is the class name used by many system dialogs. Don't ask me why Microsoft chose that as the class name. They are at liberty to call a class what they like. Fred or Sally could be equally valid class names.
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?
Hi, Good Morning,
Yes, When the Application "CubeCom" is started.
Under the "View System Windows", there is
1) TApplication "Phase 2 Cube HCI"
2) TMainForm "CubeCom"
When setFocus is used on either one, it will make the same main application windows active.
When the error that I want to intercept occurs,
Under the "View System Windows", there is
1) TApplication "Phase 2 Cube HCI"
2) TMainForm "CubeCom"
3) #32770 "Phase 2 Cube HCI"
My main objective is to let 3) #32770 "Phase 2 Cube HCI" trigger a subrountine. But if I used "OnEvent>WINDOW_OPEN,Phase 2 Cube HCI,2,ErrorDetect "; the onEvent is triggered by the detection of 1) TApplication "Phase 2 Cube HCI". I am struck at this point.
Or it there another way, to do it. I find it very hard to do because "the error I want to intercept" may appear at any point of time during my test script execution.
Please advise.
Thanks and have a nice day!
Yes, When the Application "CubeCom" is started.
Under the "View System Windows", there is
1) TApplication "Phase 2 Cube HCI"
2) TMainForm "CubeCom"
When setFocus is used on either one, it will make the same main application windows active.
When the error that I want to intercept occurs,
Under the "View System Windows", there is
1) TApplication "Phase 2 Cube HCI"
2) TMainForm "CubeCom"
3) #32770 "Phase 2 Cube HCI"
My main objective is to let 3) #32770 "Phase 2 Cube HCI" trigger a subrountine. But if I used "OnEvent>WINDOW_OPEN,Phase 2 Cube HCI,2,ErrorDetect "; the onEvent is triggered by the detection of 1) TApplication "Phase 2 Cube HCI". I am struck at this point.
Or it there another way, to do it. I find it very hard to do because "the error I want to intercept" may appear at any point of time during my test script execution.
Please advise.
Thanks and have a nice day!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This will work:
This uses the WINDOW_NEWACTIVE event and each time a new foreground window is detected it looks to see if it is the #32770/Phase 2 Cube HCI window. It uses FindWindow API to get the handle of that window and compares that to the active window.
Code: Select all
OnEvent>WINDOW_NEWACTIVE,0,0,NewWin
..
..
..
SRT>NewWin
//See if the new active window is our #32770/Phase 2 Cube HCI error window
Let>WIN_USEHANDLE=1
GetActiveWindow>ActiveHwnd,x,y
Let>WIN_USEHANDLE=0
LibFunc>user32,FindWindowA,ErrorHwnd,#32770,Phase 2 Cube HCI
//MessageModal>%ErrorHwnd% %ActiveHwnd%
If>ActiveHwnd=ErrorHwnd
//Yes, new active window is the error window! Restart app or whatever ....
Endif
End>NewWin
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?