poppe Posted February 23, 2012 Share Posted February 23, 2012 HelloI am automating the installation of my application.I use winwait to wait for the next window to appear, then controlsend commands.WinWait("Setup - My application","") ControlSend("Setup - My application", "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") WinWait("Setup - My application","") ControlSend("Setup - My application", "", "[CLASS:Button; INSTANCE:2]", "{ENTER}") WinWait("Setup - My application","") ControlSend("Setup - My application", "", "[CLASS:Button; INSTANCE:2]", "{ENTER}")The window names are identical and winwait does not seem to like it.In the help file it says i can use: text [optional] The text of the window to check. Some of the windows have lots of text, for example: "You are now installing... etc. etc."How can i identify the different windows with winwait?What is the proper use of this text option? Link to comment Share on other sites More sharing options...
AlmarM Posted February 23, 2012 Share Posted February 23, 2012 Take a look at WinGetTitle. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
poppe Posted February 24, 2012 Author Share Posted February 24, 2012 (edited) Thanks, but that function returns the same title as i get by using the info tool. All the windows are identical Title: "Setup - my application" - Class: "TWizardForm" WinWait does not know the difference between them, and the script runs through in an instant. It should always wait until the next window appears. WinWait("Setup - My application","") ControlSend("Setup - My application", "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") WinWait("Setup - My application","") ; ; script execution needs to wait at this point for the next window to appear, but now it does not. ; ; The application is unpacking files during this period, and the script ; should wait for that action to finish. ; ControlSend("Setup - My application", "", "[CLASS:Button; INSTANCE:2]", "{ENTER}") WinWait("Setup - My application","") ControlSend("Setup - My application", "", "[CLASS:Button; INSTANCE:2]", "{ENTER}") How can i make the script to wait for the next window to appear? Edited February 24, 2012 by poppe Link to comment Share on other sites More sharing options...
Andy2520 Posted May 21, 2013 Share Posted May 21, 2013 Even i am faceing same issue can any one do let us know how to go for above issue Link to comment Share on other sites More sharing options...
jdelaney Posted May 21, 2013 Share Posted May 21, 2013 (edited) WinList()...loop through the returned array WinList accepts any of these: from helpfile: Window Titles and Text (Advanced) TITLE - Window title CLASS - The internal window classname REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2) REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2) LAST - Last window used in a previous AutoIt command ACTIVE - Currently active window X Y W H - The position and size of a window INSTANCE - The 1-based instance when all given properties match easiest way for installers is to do silent installs, or use text as well to ID windows. Edited May 21, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
LarryDalooza Posted May 21, 2013 Share Posted May 21, 2013 If one shows up first, then WinWait() returns a "handle"... use that handle for that window.... The next window that shows up will have a different "handle". Now you have enough to differentiate the windows.... just apply logic. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
Shrapnel Posted May 21, 2013 Share Posted May 21, 2013 (edited) Try this: Local $screen1HWND = WinWait("Setup - My application","") If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ; This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen1HWND, "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") Local $screen2HWND = WinWait("Setup - My application","") If Not WinActive($screen2HWND) Then WinActivate($screen2HWND); This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen2HWND, "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") Local $screen3HWND = WinWait("Setup - My application","") If Not WinActive($screen3HWND) Then WinActivate($screen3HWND); This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen3HWND, "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") Edited May 21, 2013 by Shrapnel Link to comment Share on other sites More sharing options...
jdelaney Posted May 21, 2013 Share Posted May 21, 2013 (edited) no point in answering the question of the original poster...this is a dug-up post. Your script would potentially fail, if the first window is grabbed as the second window, since you do no wait for the first window to close first (could take upwards of a second to close, so you would grab the same button as the first, which is not going to fulfill the second window)...or, you should loop until the hwnd of the second window does not match that of the first. Edited May 21, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Shrapnel Posted May 21, 2013 Share Posted May 21, 2013 (edited) Lol I didn't even look at the dates Anyways, good point on waiting for screen to close... so it should be like this then, correct? (assuming {ENTER} closes the window) Local $screen1HWND = WinWait("Setup - My application","") If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ; This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen1HWND, "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") Do Sleep(100) Until Not WinExists($screen1HWND) Local $screen2HWND = WinWait("Setup - My application","") If Not WinActive($screen2HWND) Then WinActivate($screen2HWND); This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen2HWND, "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") Do Sleep(100) Until Not WinExists($screen2HWND) Local $screen3HWND = WinWait("Setup - My application","") If Not WinActive($screen3HWND) Then WinActivate($screen3HWND); This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen3HWND, "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") Do Sleep(100) Until Not WinExists($screen3HWND) Edited May 21, 2013 by Shrapnel Link to comment Share on other sites More sharing options...
jdelaney Posted May 21, 2013 Share Posted May 21, 2013 (edited) that should be safe ...last thing I would add are fail safes, such as for application errors...so I would add timerinit/timerdiff on the do loops, so after a defined max time, the script can be ended (stop indefinite loops)...would also change those controlsends to controlclicks(but I know you just copied those in). Edited May 21, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Shrapnel Posted May 21, 2013 Share Posted May 21, 2013 Thank you for the tips! Link to comment Share on other sites More sharing options...
Andy2520 Posted May 23, 2013 Share Posted May 23, 2013 I Team, I issue for idetifying same title windows.First window should wait till second window open . How do i read content/text of second window .i will wait on first window only First window Title: Configuration Button on window: Ok ,Cancel and Next Content or text on window: Welcome Second window Title" Configuration Button on window: Ok ,Cancel and Next Content or text on window: USerinformation How do i wait till second window appear .I want to read content/text on second window . Please help me. I have define below below code .It will get Local $screen1HWND = WinWait(" Client Configuration","&Next") If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ; This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen1HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "{ENTER}") Do Sleep(100) stop on second window Until Not WinExists($screen1HWND) Local $screen2HWND = WinWait("Client Configuration", "&Next") If Not WinActive($screen2HWND) Then WinActivate($screen2HWND) Send("459278") Sleep(1000) Send("{TAB}") ControlSend($screen2HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "{ENTER}") Do Sleep(100) Until Not WinExists($screen2HWND) Link to comment Share on other sites More sharing options...
Shrapnel Posted May 23, 2013 Share Posted May 23, 2013 Aniiii, I am having trouble understanding what you want your script to do. Can you try to explain better exactly what you are trying to accomplish? Also, when posting examples of AutoIt code, please use the code button in your post toolbar to format the text. it just makes it easier for everyone Link to comment Share on other sites More sharing options...
jdelaney Posted May 23, 2013 Share Posted May 23, 2013 (edited) use this function: winlist("yourtitle") loop through the returned array for the window NOT equal to the hwnd of the first window...that's your new window or, in your include Instance:2 in your winwait function Use the helpfile for samples Edited May 23, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Andy2520 Posted May 25, 2013 Share Posted May 25, 2013 Hi Sharpnel, I want to configure the Messaging client i.e lotus notes automatically once user enter his details. I have taken input from user and it should enter automatically on configuration window . in this configuration we have Same Title window ,and each window has different content .Now i want to identify content of window and wait the window or if error comes while configuring we have to display msg to user cant be processed . Eg of window contains First window Title: Configuration Button on window: Ok ,Cancel and Next Content or text on window: Welcome Second window Title" Configuration Button on window: Ok ,Cancel and Next Content or text on window: User information Third window Title" Configuration Button on window: Ok ,Cancel and Next Content/text on window : Local Area network Now above example . I want to wait till second window appear .Some time it will open other ERROR window .IF error window come i have to Exit . Local $screen1HWND = WinWait(" Client Configuration","&Next") If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ; This is just to make the script more robust and make sure the window is active before sending a command ControlSend($screen1HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "{ENTER}") Do Sleep(100) stop on second window Until Not WinExists($screen1HWND) Local $screen2HWND = WinWait("Client Configuration", "&Next") If Not WinActive($screen2HWND) Then WinActivate($screen2HWND) Send("459278") Sleep(1000) Send("{TAB}") ControlSend($screen2HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "{ENTER}") Do Sleep(100) Until Not WinExists($screen2HWND) Link to comment Share on other sites More sharing options...
Shrapnel Posted May 25, 2013 Share Posted May 25, 2013 (edited) Aniiii, Try this and let me know what happens. you will have to add some code, but it should get you pointed in the right direction: expandcollapse popupLocal $screen1HWND = WinWait(" Client Configuration","&Next") If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ControlClick($screen1HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "left", 1) Local $nextWindow = getNextWinTitle($screen1HWND) ; pass the handle of the window you just closed. it will return the next active window ; Now that you have the handle of the new active window, you can figure out if it is an error ; message, or if it is the "User Information" window and handle accordingly with an "If" statement If WinGetTitle($nextWindow) = "Client Configuration" Then Local $screen2HWND = WinWait("Client Configuration", "&Next") If Not WinActive($screen2HWND) Then WinActivate($screen2HWND) Send("459278") Sleep(1000) Send("{TAB}") ControlClick($screen1HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "left", 1) Do Sleep(100) Until Not WinExists($screen2HWND) ElseIf WinGetTitle($nextWindow) = "Error" Then MsgBox(0, "", "Error message!") Exit Else MsgBox(0, "", "Unexpected window!") Exit EndIf ; getNextWinTitle function will wait until the provided window no longer ; exists and then gives you the handle of the new active window Func getNextWinTitle($_originalWindowHWND) Local $originalWinTitle = WinGetTitle($_originalWindowHWND) Local $nextWinTitle = "" Do Sleep(100) $nextWinTitle = WinGetTitle("[active]") Until $nextWinTitle <> $originalWinTitle Return $nextWinTitle EndFunc Edited May 25, 2013 by Shrapnel Link to comment Share on other sites More sharing options...
Andy2520 Posted May 29, 2013 Share Posted May 29, 2013 No its not working .. I guess we have have to use OPT function . I dont know how to use it ... Please help me how can use that function Link to comment Share on other sites More sharing options...
Shrapnel Posted May 29, 2013 Share Posted May 29, 2013 Can you post the code that you tried that did not work? Also, I am not sure what you mean by "OPT Function" Link to comment Share on other sites More sharing options...
Andy2520 Posted May 30, 2013 Share Posted May 30, 2013 HI, Find the below code expandcollapse popupSend("#r") WinWaitActive("Run") Send("notes.exe{Enter}") Local $screen1HWND = WinWait("IBM Lotus Notes 8.5.2 Client Configuration","&Next") If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ControlClick($screen1HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "left", 1) Local $nextWindow = getNextWinTitle($screen1HWND) ; pass the handle of the window you just closed. it will return the next active window ; Now that you have the handle of the new active window, you can figure out if it is an error ; message, or if it is the "User Information" window and handle accordingly with an "If" statement If WinGetTitle($nextWindow) = "IBM Lotus Notes 8.5.2 Client Configuration" Then Local $screen2HWND = WinWait("IBM Lotus Notes 8.5.2 Client Configuration", "&Next") If Not WinActive($screen2HWND) Then WinActivate($screen2HWND) Send("459278nkj") Sleep(1000) Send("{TAB}") Send("IBRT.MAgic.com) ControlClick($screen1HWND, "", "[CLASS:IRIS.bmpbutton; INSTANCE:1]", "left", 1) Do Sleep(100) Until Not WinExists($screen2HWND) ElseIf WinGetTitle($nextWindow) = "IBM Lotus Notes" Then MsgBox(0, "", "Error message!") Exit Else MsgBox(0, "", "Unexpected window!") Exit EndIf ; getNextWinTitle function will wait until the provided window no longer ; exists and then gives you the handle of the new active window Func getNextWinTitle($_originalWindowHWND) Local $originalWinTitle = WinGetTitle($_originalWindowHWND) Local $nextWinTitle = "" Do Sleep(100) $nextWinTitle = WinGetTitle("[active]") Until $nextWinTitle <> $originalWinTitle Return $nextWinTitle EndFunc Link to comment Share on other sites More sharing options...
Shrapnel Posted May 30, 2013 Share Posted May 30, 2013 It looks like you are missing a " on Send("IBRT.MAgic.com) Is this the part that is failing? Also, you should look into using the ControlSetText commands instead of using Send. It's much more reliable. 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