bourny Posted January 16, 2006 Share Posted January 16, 2006 I am trying to control a window using variables to substitute the title and text options. This does not appear to work as the WinWait / WinClose / WinKill may not accept variables. Does anyone have any ideas how to get around this ... Example $Window1 = '"Window Title"' $window2 = '"Window Text"' WinActivate($Window1, $window2) WinClose($Window1, $window2) WinKill($Window1, $window2) My reason for doing this is to link a default install script to another application script - the default script needs to beable to terminate the application if a winwait timeout occurs. Since the application script could fall over at any stage I need to beable to pipe the failed window to the winclose / winkill function. Open to ideas Link to comment Share on other sites More sharing options...
Valuater Posted January 16, 2006 Share Posted January 16, 2006 how about WinGetHandle -------------------------------------------------------------------------------- Retrieves the internal handle of a window. WinGetHandle ( "title" [, "text"] ) Parameters title The title of the window to read. See Title special definition. text [optional] The text of the window to read. Return Value Success: Returns handle to the window. Failure: Returns "" (blank string) and sets @error to 1 if no window matches the criteria. Remarks This function is for use with the advanced WinTitleMatchMode options that allow you to use classnames and handles to specify windows rather than "title" and "text". Once you have obtained the handle you can access the required window even if its title changes. ; Identify the Notepad window that contains the text "this one" and get a handle to it Run("notepad.exe ") WinWait("") Send("this one" & @CRLF) ; Change into the WinTitleMatchMode that supports classnames and handles AutoItSetOption("WinTitleMatchMode", 4) ; Get the handle of a notepad window that contains "this one" $handle = WinGetHandle("classname=Notepad", "this one") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else ; Send some text directly to this window's edit control ControlSend($handle, "", "Edit1", "AbCdE") EndIf 8) Link to comment Share on other sites More sharing options...
greenmachine Posted January 16, 2006 Share Posted January 16, 2006 $AutoItHelp = "AutoIt Help" WinActivate ($AutoItHelp) That worked for me.... Maybe it has to do with the number of quotes you used? Link to comment Share on other sites More sharing options...
bourny Posted January 16, 2006 Author Share Posted January 16, 2006 Thanks, Reply to Valuater = This looks good however this relies on me picking out the correct window from many open of that given title. - I will keep this as I am sure this will solve another problem - Thanks Reply to greenmachine = Spot on..... This is exactly what I need - I was nearly there but tried to overcomplicate the variable by defining the quotes(using reverse quotes to wrap it) Tesed on my application and works a treat.... 5 stars to you... Thanks all for your help and time spent... problem solved. bourny 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