haridsv Posted May 10, 2004 Share Posted May 10, 2004 Hello, I came across the AutoIt utility recently when I was searching for ways to automate CygWin installation, and I thought it is cool. I was able to successfully customize and enhance the script that I found on the net, and use it across our development. I am impressed enough that now I am trying to use for my personal automation needs. Currently I am trying to simplify searches under Vantive bug tracking system using its client, as the version we use doesn't have a way to set views or save searches. I was able to get Vantive started and enter all the search fields entered etc. successfully. With more enthusiasm, when I tried to improve the script further to avoid starting a new copy of the application every time, I am stuck with WinWaitActive command getting stuck. I put debugging messages and concluded that the command basically takes for ever and never returns. While the command is stuck, if I manually activate the Vantive window, the script continues immediately. I originally wrote the script for V2 (with the equivalent IfWinNotActive getting stuck), but I wanted to check if V3 had this problem fixed, so I installed V3 and used the converter to quickly convert the script to V3. But even V3 seems to have the same problem. Here is the script that the converter generated (without the part that actually fills in the search fields). ; V2.64 to V3.0.93 (Version 1.0.4) ; Converted with AutoItV2toV3 [Version 1.0.5] ; (C) Copyright 2004 J-Paul Mesnage. ; Start vantive. if WinExists ( 'Vantive System', '' ) then $__msgbox = MsgBox ( 0, 'Debug', 'Vantive dialog found' ) else ;; SkipStart Run ( 'C:\apps\Vantive32\vantiv32.exe', 'C:\apps\Vantive32' ) ; Wait for the login prompt and press Enter. WinWaitActive ( 'The Vantive Corporation' ) Send ( '{ENTER}' ) endif ; Wait for the main window to appear. $__msgbox = MsgBox ( 0, 'Debug', 'SkipStart label start' ) if NOT WinActive ( 'Vantive System', '' ) then WinWaitActive ( 'Vantive System' ) endif $__msgbox = MsgBox ( 0, 'Debug', 'Sleeping for 20' ) Sleep ( 20 ) $__msgbox = MsgBox ( 0, 'Debug', 'wait done.' ) ; Open defects. Send ( '!FO{Enter}' ) $__msgbox = MsgBox ( 0, 'Debug', 'Sent keys to open search box.' ) Sleep ( 50 ) $__msgbox = MsgBox ( 0, 'Debug', 'done sleeping for 50' ) Send ( '!l' ) The first WinWaitActive() will only get executed if the application is not already started, and works fine. The problem is with the second call, and when the application is not currently active. I would appreciate if anyone can help me resolve this issue. Thanks a lot, Hari Link to comment Share on other sites More sharing options...
haridsv Posted May 10, 2004 Author Share Posted May 10, 2004 Coool... your function works perfectly well. I removed the debug code and got the following working: if NOT WinExists ( 'Vantive System', '' ) then ; Start vantive. Run ( 'C:\apps\Vantive32\vantiv32.exe', 'C:\apps\Vantive32' ) ; Wait for the login prompt and press Enter. WinWaitActive ( 'The Vantive Corporation' ) Send ( '{ENTER}' ) endif EnsureActive("Vantive System") ; Open defects window. Send ( '!FO{Enter}' ) Sleep ( 50 ) Send ( '!l' ) Func EnsureActive($szTitle) WinWait($szTitle,"",90) While Not WinActive($szTitle) WinActivate($szTitle) Sleep(100) Wend WinWaitActive($szTitle,"",90) EndFunc Amazing, no unnecessary sleeps, and the script runs faster too. Now, can you also help me with the following simple code that includes the above and does additional stuff. Basically, it prompts the user for the bugid and opens it up (worked fine with V2). #include "OpenVantivewindow.au3" ; Prompt for bug id. $BugID = InputBox ( 'AutoIt', 'Enter the bug ID:' ) ; Enter bugid. Send ( $BugID ) ; Start the search. Send ( '{Enter}' ) ; Open the bug. Send ( '{Enter}' ) The problem is that the first Send() doesn't send the value of $BugId which was just read in from the user. Strangely enough, if I add a debug MsgBox() (and no other change), it prints the bugid that I enter correctly, and the following Send() works as expected: #include "OpenVantivewindow.au3" ; Prompt for bug id. $BugID = InputBox ( 'AutoIt', 'Enter the bug ID:' ) MsgBox(1, "Debug", $BugID) ; Enter bugid. Send ( $BugID ) ; Start the search. Send ( '{Enter}' ) ; Open the bug. Send ( '{Enter}' ) Thanks a lot for a quick response. Hari Link to comment Share on other sites More sharing options...
haridsv Posted May 10, 2004 Author Share Posted May 10, 2004 Fantastic. So I just added another EnsureActive() call (the function you created in the first response) and it started working fine. And guess what, I love the tool even more now. Thanks again, Hari Link to comment Share on other sites More sharing options...
emmanuel Posted May 11, 2004 Share Posted May 11, 2004 EnsureActive("Title") ;... ;... Func EnsureActive($szTitle) WinWait($szTitle,"",90) While Not WinActive($szTitle) WinActivate($szTitle) Sleep(100) Wend WinWaitActive($szTitle,"",90) EndFunctook what you'd done, added another bit for being able to ensure with text as well as title, wah-la: EnsureActive("script scraps", "FolderView") ;... ;... Func EnsureActive($SZTITLE, $SZTEXT) WinWait($SZTITLE, $SZTEXT, 90) While Not WinActive($SZTITLE, $SZTEXT) WinActivate($SZTITLE, $SZTEXT) Sleep(100) Wend WinWaitActive($SZTITLE, $SZTEXT, 90) EndFunc ;==>EnsureActive just added that to my catchall script scraps folder for future use... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now