 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Camille Moore
Joined: 30 Jul 2002 Posts: 19
|
|
Window function failures? |
|
Have you had any reports of the Window functions not acting as expected?
Here is my situation:
I need to execute a set of activities that I can only accomplish by using the Sendkeys function extensively. However, as you know, the key failure point is some other process (or person) changing the window focus before the job can complete. The best solution, as I've read on this forum, is to use a combination of the WindowFind, WindowActivate and Sendkeys JAL functions.
In order to test this script, first of all, I must close or disable all programs running on my PC that are likley to change the window focus, however briefly or unobtrusively. I found that these programs cause the JAL script to behave erratically. Even when I do this, I still get 24x7 crashes on the WindowFind or the WindowGetChild functions. Do you have any idea why this might be happening?
|
|
Tue Sep 17, 2002 11:42 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
Re: Window function failures? |
|
If you properly use WindowFind and a window you are searching has a unique title not used in other applications you should be fine. However, if you attempt to find a window with a very generic title you can hit the wrong application. In the last case with a generic title you can find the proper window belonging to your application if you start with ProcessGetWindow which will return the first window of your program and then use other Window... statement to drill-down to the right window. A very helpful utility is a Spy program provided with the most C/C++ development systems. Using this utility you can graphically find out "relations" between your program windows and then you can easily code appropriate Windows statements to find handle of the right window. When you use WindowActivate make sure you call it for a top-level window in your application and not for a button on a dialog box. A keystroke send stray key cause serious problems leading to erratic behavior of other applications including 24x7 itself. If you want me to help you with the script you are developing please post your script here. : Have you had any reports of the Window functions not acting as expected? : Here is my situation: I need to execute a set of activities that I can only : accomplish by using the Sendkeys function extensively. However, as you : know, the key failure point is some other process (or person) changing the : window focus before the job can complete. The best solution, as I've read : on this forum, is to use a combination of the WindowFind, WindowActivate : and Sendkeys JAL functions. : In order to test this script, first of all, I must close or disable all : programs running on my PC that are likley to change the window focus, : however briefly or unobtrusively. I found that these programs cause the : JAL script to behave erratically. Even when I do this, I still get 24x7 : crashes on the WindowFind or the WindowGetChild functions. Do you have any : idea why this might be happening?
|
|
Tue Sep 17, 2002 12:06 pm |
|
 |
Camille Moore
Joined: 30 Jul 2002 Posts: 19
|
|
Re: Window function failures? |
|
Here is the script: Dim( eEntrprs_Running, boolean, false ) Dim( RetCode, number ) Dim( eEntrprsProgId, number ) Dim( eEntrprsWindow, number ) Dim( eEntrprsChildWindow, number ) IsTaskRunning( "Dynamics.exe", eEntrprs_Running ) If( eEntrprs_Running, eEntrprsContinue, eEntrprsStart ) eEntrprsStart: GoTo RunChkLinks eEntrprsContinue: ProcessGetID( "Dynamics.exe", eEntrprsProgId ) ProcessKill( eEntrprsProgId ) Wait( 20 ) GoTo RunChkLinks RunChkLinks: Run( "C:\eEntrprs\Dynamics.exe C:\eEntrprs\Dynamics.set", "C:\eEntrprs\\", RetCode ) Wait( 20 ) WindowFind( "Great Plains%", eEntrprsWindow ) WindowActivate( eEntrprsWindow) WindowGetChild( eEntrprsWindow, eEntrprsChildWindow ) WindowActivate( eEntrprsChildWindow ) GetLastError( RetCode ) SendKeys( "{TAB}{TAB}t{SHIFT}({TAB})pwd{ENTER}" ) Wait( 20 ) WindowActivate( eEntrprsWindow ) SendKeys( "{TAB}{ENTER}" ) Wait( 20 ) WindowActivate( eEntrprsWindow ) SendKeys( "{ALT}(F){WAIT 2}M{DOWN}{WAIT 2} " ) Wait( 10 ) WindowActivate( eEntrprsWindow ) SendKeys( "{TAB}{TAB}{TAB} {TAB}{TAB}{TAB}" ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) SendKeys( "{DOWN}{DOWN}" ) SendKeys( "{WAIT 5} " ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB} {TAB}{TAB} " ) SendKeys( "{TAB}c{SHIFT}(:)\\e{SHIFT}(E)ntrprs{SHIFT}(_C)hklinks.txt" ) SendKeys( "{TAB}T{TAB}{RIGHT}{TAB}" ) Wait( 10 ) WindowActivate( eEntrprsWindow ) SendKeys( " " ) Wait( 180 ) MailSendWithAttachment( "sender", "sendpwd", "email1", "eEnterprise Check Links results (Testing)", ".", "c:\\eEntrprs_ChkLinks.txt" ) SendKeys( "{ALT}(F)X" ) : If you properly use WindowFind and a window you are searching has a unique : title not used in other applications you should be fine. However, if you : attempt to find a window with a very generic title you can hit the wrong : application. : In the last case with a generic title you can find the proper window : belonging to your application if you start with ProcessGetWindow which : will return the first window of your program and then use other Window... : statement to drill-down to the right window. A very helpful utility is a : Spy program provided with the most C/C++ development systems. Using this : utility you can graphically find out "relations" between your : program windows and then you can easily code appropriate Windows : statements to find handle of the right window. : When you use WindowActivate make sure you call it for a top-level window in : your application and not for a button on a dialog box. : A keystroke send stray key cause serious problems leading to erratic behavior : of other applications including 24x7 itself. : If you want me to help you with the script you are developing please post : your script here.
|
|
Tue Sep 17, 2002 4:05 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
Re: Window function failures? |
|
Try the following: Dim( RetCode, number ) Dim( WinTitle, string ) Dim( eEntrprs_Running, boolean, false ) Dim( eEntrprsProgId, number ) Dim( eEntrprsWindow, number ) Dim( eEntrprsChildWindow, number ) IsTaskRunning( "Dynamics.exe", eEntrprs_Running ) IfThen( eEntrprs_Running, RunChkLinks ) ProcessGetID( "Dynamics.exe", eEntrprsProgId ) ProcessKill( eEntrprsProgId ) Wait( 20 ) RunChkLinks: Run( "C:\eEntrprs\Dynamics.exe C:\eEntrprs\Dynamics.set", "C:\eEntrprs", RetCode ) Wait( 20 ) WindowFind( "Great Plains%", eEntrprsWindow ) IfThen( eEntrprsWindow, GET_CHILD ) RaiseError( "Unable to find application window. Job aborted." ) GET_CHILD: // DEBUG get window title and write log message WindowGetTitle( eEntrprsWindow, WinTitle ) LogAddMessageEx( "INFO", @V"job_id", "@V"job_name"", WinTitle ) WindowGetChild( eEntrprsWindow, eEntrprsChildWindow ) IfThen( eEntrprsChildWindow, SEND_KEYS ) RaiseError( "Unable to find child window. Job aborted." ) SEND_KEYS: // DEBUG get window title and write log message WindowGetTitle( eEntrprsChildWindow, WinTitle ) LogAddMessageEx( "INFO", @V"job_id", "@V"job_name"", WinTitle ) WindowActivate( eEntrprsChildWindow ) SendKeys( "{TAB}{TAB}t{SHIFT}{TAB}pwd{ENTER}" ) Wait( 20 ) WindowActivate( eEntrprsWindow ) SendKeys( "{TAB}{ENTER}" ) Wait( 20 ) WindowActivate( eEntrprsWindow ) SendKeys( "{ALT}FM{DOWN}{WAIT 2} " ) Wait( 10 ) WindowActivate( eEntrprsWindow ) SendKeys( "{TAB}{TAB}{TAB} {TAB}{TAB}{TAB}" ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}" ) SendKeys( "{WAIT 5} " ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) WindowActivate( eEntrprsWindow ) SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB} {TAB}{TAB} " ) WindowActivate( eEntrprsWindow ) SendKeys( "{TAB}c:\eEntrprs_Chklinks.txt{TAB}T{TAB}{RIGHT}{TAB}" ) Wait( 10 ) WindowActivate( eEntrprsWindow ) SendKeys( " " ) Wait( 180 ) MailSendWithAttachment( "sender", "sendpwd", "email1", "eEnterprise Check Links results (Testing)", ".", "c:\\eEntrprs_ChkLinks.txt" ) SendKeys( "{ALT}FX" )
|
|
Tue Sep 17, 2002 5:38 pm |
|
 |
Camille Moore
Joined: 30 Jul 2002 Posts: 19
|
|
Re: Window function failures? |
|
Well, the window title it found for the child does not match what I see on screen . WindowGetNext? : Try the following: Dim( RetCode, number ) : Dim( WinTitle, string ) : Dim( eEntrprs_Running, boolean, false ) : Dim( eEntrprsProgId, number ) : Dim( eEntrprsWindow, number ) : Dim( eEntrprsChildWindow, number ) : IsTaskRunning( "Dynamics.exe", eEntrprs_Running ) : IfThen( eEntrprs_Running, RunChkLinks ) : ProcessGetID( "Dynamics.exe", eEntrprsProgId ) : ProcessKill( eEntrprsProgId ) : Wait( 20 ) : RunChkLinks: Run( "C:\eEntrprs\Dynamics.exe : C:\eEntrprs\Dynamics.set", "C:\eEntrprs", RetCode ) : Wait( 20 ) : WindowFind( "Great Plains%", eEntrprsWindow ) : IfThen( eEntrprsWindow, GET_CHILD ) : RaiseError( "Unable to find application window. Job aborted." ) : GET_CHILD: // DEBUG get window title and write log message : WindowGetTitle( eEntrprsWindow, WinTitle ) : LogAddMessageEx( "INFO", @V"job_id", : "@V"job_name"", WinTitle ) : WindowGetChild( eEntrprsWindow, eEntrprsChildWindow ) : IfThen( eEntrprsChildWindow, SEND_KEYS ) : RaiseError( "Unable to find child window. Job aborted." ) : SEND_KEYS: // DEBUG get window title and write log message : WindowGetTitle( eEntrprsChildWindow, WinTitle ) : LogAddMessageEx( "INFO", @V"job_id", : "@V"job_name"", WinTitle ) : WindowActivate( eEntrprsChildWindow ) : SendKeys( "{TAB}{TAB}t{SHIFT}{TAB}pwd{ENTER}" ) : Wait( 20 ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{TAB}{ENTER}" ) : Wait( 20 ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{ALT}FM{DOWN}{WAIT 2} " ) : Wait( 10 ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{TAB}{TAB}{TAB} {TAB}{TAB}{TAB}" ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}" ) : SendKeys( "{WAIT 5} " ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB}{TAB}{TAB}" ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{DOWN}{DOWN}{ENTER}{TAB}{TAB} {TAB} {TAB}{TAB} " ) : WindowActivate( eEntrprsWindow ) : SendKeys( "{TAB}c:\eEntrprs_Chklinks.txt{TAB}T{TAB}{RIGHT}{TAB}" ) : Wait( 10 ) : WindowActivate( eEntrprsWindow ) : SendKeys( " " ) : Wait( 180 ) : MailSendWithAttachment( "sender", "sendpwd", : "email1", "eEnterprise Check : Links results (Testing)", ".", : "c:\\eEntrprs_ChkLinks.txt" ) : SendKeys( "{ALT}FX" )
|
|
Tue Sep 17, 2002 6:27 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
Re: Window function failures? |
|
If the "child" window you are searching has a unique title why not to WindowFind it Otherwise you may need a bunch of WindowGetNext and WindowGetChild calls to reach it. A Spy program I mentioned before can help you greatly by displaying the window relations. : Well, the window title it found for the child does not match what I see on : screen . WindowGetNext?
|
|
Tue Sep 17, 2002 7:25 pm |
|
 |
Camille Moore
Joined: 30 Jul 2002 Posts: 19
|
|
Re: Window function failures? |
|
Hi, I tried the WindowGetNext function once more and got a window totally unrelated to the application. Is it possible that there are hidden windows that I may encounter before the one I intend to find?
|
|
Thu Sep 19, 2002 10:19 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
Re: Window function failures? |
|
If you apply WindowGetNext to the top level window in your application you should reach another top level window which is most likely will belong to another application. Please use some Windows Spy program to find out window relations within your application. Again you may need to call a sequence of WindowGetChild and WindowGetNext to navigate from the top level window in your application to the window you want to send keystrokes to. You can use for example the trial version of WinSpector program which will graphically show your windows hierarhy. WinSpector can be downloaded at http://www.gipsysoft.com/articles/winspector/Winspector.zip After you install and run WinSpector right click on the Window tree on the left side and shoose "Expand all windows" fro mthe popup menu. : Hi, I tried the WindowGetNext function once more and got a window totally : unrelated to the application. Is it possible that there are hidden windows : that I may encounter before the one I intend to find?
|
|
Thu Sep 19, 2002 10:36 am |
|
 |
Camille Moore
Joined: 30 Jul 2002 Posts: 19
|
|
Re: Window function failures? |
|
Aha! It wasn't a child!!! It was a Main window!!! I can't believe it was that simple - thanks!!!
|
|
Thu Sep 19, 2002 12:05 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|