onevent confusion
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 6
- Joined: Thu Apr 10, 2008 6:20 pm
onevent confusion
I have two onevent's that notice when two different window titles open. the object is to hit the enter key when the window opens
Code:
OnEvent>WINDOW_OPEN,Information,1,Simple,Information
OnEvent>WINDOW_OPEN,Warning,1,Simple,Warning
WaitWindowOpen>Startup Options
Exit
SRT>Simple
SetFocus>%Simple_Var_1%*
MessageModal>Window Closer
Wait>.5
Press Enter
Wait>.5
Let>Simple_Var_1=
End>Simple
There are sometimes up to 2 Warning windows that show up before the Information Window comes opens The Warning windows are never closed the message never comes up in the Simple subroutine. Yet Information window works perfectly every time.
Help?
I tried
OnEvent>WINDOW_OPEN,Warning,2,Simple,Warning
no effect
I tried
OnEvent>WINDOW_OPEN,Warning,1,Simple,Warning
OnEvent>WINDOW_OPEN,Information,1,Simple,Information
no effect
Code:
OnEvent>WINDOW_OPEN,Information,1,Simple,Information
OnEvent>WINDOW_OPEN,Warning,1,Simple,Warning
WaitWindowOpen>Startup Options
Exit
SRT>Simple
SetFocus>%Simple_Var_1%*
MessageModal>Window Closer
Wait>.5
Press Enter
Wait>.5
Let>Simple_Var_1=
End>Simple
There are sometimes up to 2 Warning windows that show up before the Information Window comes opens The Warning windows are never closed the message never comes up in the Simple subroutine. Yet Information window works perfectly every time.
Help?
I tried
OnEvent>WINDOW_OPEN,Warning,2,Simple,Warning
no effect
I tried
OnEvent>WINDOW_OPEN,Warning,1,Simple,Warning
OnEvent>WINDOW_OPEN,Information,1,Simple,Information
no effect
Your syntax is not correct. You can't pass values to the subroutine in the onevent. The easiest thing from the way you've written this might be to create two subroutines that each call the "simple" subroutine.
OnEvent>WINDOW_OPEN,Information,1,Simple1
OnEvent>WINDOW_OPEN,Warning,1,Simple2
WaitWindowOpen>Startup Options
Exit
SRT>Simple1
Gosub>simple,Information
END>Simple1
SRT>Simple2
Gosub>simple,Warning
END>Simple2
SRT>Simple
SetFocus>%Simple_Var_1%*
MessageModal>Window Closer
Wait>.5
Press Enter
Wait>.5
Let>Simple_Var_1=
End>Simple
OnEvent>WINDOW_OPEN,Information,1,Simple1
OnEvent>WINDOW_OPEN,Warning,1,Simple2
WaitWindowOpen>Startup Options
Exit
SRT>Simple1
Gosub>simple,Information
END>Simple1
SRT>Simple2
Gosub>simple,Warning
END>Simple2
SRT>Simple
SetFocus>%Simple_Var_1%*
MessageModal>Window Closer
Wait>.5
Press Enter
Wait>.5
Let>Simple_Var_1=
End>Simple
-
- Newbie
- Posts: 6
- Joined: Thu Apr 10, 2008 6:20 pm
I can
I successfully pass the paramater to the subroutine in the information onevent. and even if I take that part out there is no change to the way the script runs. Warning still does not come up. I put a message modal in the SRT>Simple so I can see if it is even called. Warning never calls the subroutine. Information always calls it and passes the parameter correctly each time.
I'm surprised. And I stand corrected.
I tested your script and found that indeed parameters CAN be passed to a subroutine through onevent. I don't have your windows to test with so I used notepad and excel and the following script works. As I open excel or notepad a message pops up with excel or notepad in the message. After I close the message the excel or notepad window is closed and the script hums along waiting for me to open either excel or notepad and the process starts again.
My next thought would be that you need an asterisk in the window name parameter for the Warning window OnEvent line.
OnEvent>WINDOW_OPEN,Warning*,1,Simple,Warning
I tested your script and found that indeed parameters CAN be passed to a subroutine through onevent. I don't have your windows to test with so I used notepad and excel and the following script works. As I open excel or notepad a message pops up with excel or notepad in the message. After I close the message the excel or notepad window is closed and the script hums along waiting for me to open either excel or notepad and the process starts again.
Code: Select all
OnEvent>WINDOW_OPEN,NotePad*,1,Simple,Notepad
OnEvent>WINDOW_OPEN,Excel*,1,Simple,Excel
Label>Loop
Wait>0.01
Goto>Loop
SRT>Simple
MessageModal>Window Closer %Simple_Var_1%
SetFocus>%Simple_Var_1%*
Wait>1
Press Alt
Press F4
Release Alt
Let>Simple_Var_1=
End>Simple
OnEvent>WINDOW_OPEN,Warning*,1,Simple,Warning
-
- Newbie
- Posts: 6
- Joined: Thu Apr 10, 2008 6:20 pm
Child Window
the suggestion is not working. The only thing I can figure is the difference bbtween these two windows is the one that is not being recognized "Warning" is a child window while the one that is being recognized "Information" is a standalone application window. could this be the source of my problem why onevent>Window_Open does not notice the Warning window at all?
Have you tried experimenting with the WF_TYPE portion of the Window_Open OnEvent> along with the added asterisk?
Let>WF_TYPE=0 - No Child Windows
Let>WF_TYPE=1 - ALL Windows (Default)
Let>WF_TYPE=2 - Visible Windows Only
Let>WF_TYPE=3 - Child Windows Only
For Example:
OnEvent>WINDOW_OPEN,Warning,0,Simple,Warning*
or
OnEvent>WINDOW_OPEN,Warning,1,Simple,Warning*
or
OnEvent>WINDOW_OPEN,Warning,2,Simple,Warning*
or
OnEvent>WINDOW_OPEN,Warning,3,Simple,Warning*
Let>WF_TYPE=0 - No Child Windows
Let>WF_TYPE=1 - ALL Windows (Default)
Let>WF_TYPE=2 - Visible Windows Only
Let>WF_TYPE=3 - Child Windows Only
For Example:
OnEvent>WINDOW_OPEN,Warning,0,Simple,Warning*
or
OnEvent>WINDOW_OPEN,Warning,1,Simple,Warning*
or
OnEvent>WINDOW_OPEN,Warning,2,Simple,Warning*
or
OnEvent>WINDOW_OPEN,Warning,3,Simple,Warning*
-
- Newbie
- Posts: 6
- Joined: Thu Apr 10, 2008 6:20 pm
-
- Newbie
- Posts: 6
- Joined: Thu Apr 10, 2008 6:20 pm
done some testing,
I definitly see that the srt is beeing triggerd twice!
Try to put WriteLn>c:\onevent.txt,result, %TIME% simple 2
instead of the messagemodal, and you'll be surprised !
here's my test:
if i open excel the srt is being called twice.
Or is it this late hour that i'm missing something?
I definitly see that the srt is beeing triggerd twice!
Try to put WriteLn>c:\onevent.txt,result, %TIME% simple 2
instead of the messagemodal, and you'll be surprised !
here's my test:
Code: Select all
OnEvent>WINDOW_OPEN,Naamlo*,1,Simple1
OnEvent>WINDOW_OPEN,Microsoft Excel*,1,Simple2
rem Naalo* is Notepad default
rem Microsoft Excel* is Microsoft Excel new map
Label>Loop
Wait>0.01
GetTime>time
Goto>Loop
SRT>Simple1
WriteLn>c:\onevent.txt,result, %TIME% SIMPLE 1
wait>0.2
SetFocus>Naamlo*
Wait>0.2
Press Alt
Press F4
Release Alt
End>Simple1
SRT>Simple2
WriteLn>c:\onevent.txt,result, %TIME% simple 2
wait>1
SetFocus>Microsoft Excel*
Wait>0.2
Press Alt
Press F4
Release Alt
End>Simple2
Or is it this late hour that i'm missing something?
Erik,
Can you run the following script while your warning window is visible? Look for the name "Warning" in the list. Its possible that the window's name is not "Warning" at its creation. The window may be created with some other title and the title gets changed to "Warning".
=====================================
Djek,
I think what you're seeing is the Onevent catching the window still open for a moment after the subroutine closes the window and finishes. Pressing Ctrl+F4 will close a window, but it will take a fraction of a second for the Operating system and the computer to respond. That fraction of a second is enough time for the OnEvent to trigger the Subroutine a second time.
Can you run the following script while your warning window is visible? Look for the name "Warning" in the list. Its possible that the window's name is not "Warning" at its creation. The window may be created with some other title and the title gets changed to "Warning".
Code: Select all
GetWindowList>list
WriteLn>c:\Windowlist.txt,wres,%list%
Run>notepad c:\Windowlist.txt
Djek,
I think what you're seeing is the Onevent catching the window still open for a moment after the subroutine closes the window and finishes. Pressing Ctrl+F4 will close a window, but it will take a fraction of a second for the Operating system and the computer to respond. That fraction of a second is enough time for the OnEvent to trigger the Subroutine a second time.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Correct. Add this line to the end of the Subroutine:Djek,
I think what you're seeing is the Onevent catching the window still open for a moment after the subroutine closes the window and finishes. Pressing Ctrl+F4 will close a window, but it will take a fraction of a second for the Operating system and the computer to respond. That fraction of a second is enough time for the OnEvent to trigger the Subroutine a second time.
WaitWindowClosed>Microsoft Excel*
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?
-
- Newbie
- Posts: 6
- Joined: Thu Apr 10, 2008 6:20 pm
JRL it was run
I ran the script as you suggested and the word Warning was in the list there were no pre or trailing characters. I was hoping you were on to something there.