rcubefather Posted October 26, 2015 Share Posted October 26, 2015 I am automating a software installation in Windows7 using AutoIt.During the installation, in between if a error window appears. I want to click ENTER.If the error window not appears then I should NOT do anything. Simply its should go to the next section.I have tried "WinActive and WinWaitActive" But its waiting for the window to appear. If window not appears its not going to the next screen.Any idea how to handle this situation? Link to comment Share on other sites More sharing options...
BrewManNH Posted October 26, 2015 Share Posted October 26, 2015 WinWait and WinWaitActive have a timeout parameter, so if the window doesn't appear within a certain time, the function stops waiting. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rcubefather Posted October 26, 2015 Author Share Posted October 26, 2015 Hi BrewManNH,As you said, YES Winwait and WinWaitActive stops waiting after the Timeout period.Any idea how to use this for optional window handling? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 26, 2015 Moderators Share Posted October 26, 2015 You could do something like this, depending on how long it would take for the optional window to come up:For $i = 1 To 10 If WinExists("Error Installing", "Wrong Credentials") Then ControlClick("Error Installing", "Wrong Credentials", "Button1") ExitLoop Else Sleep(500) EndIf NextThe bigger question would be what exactly is causing the optional window (what scenario) so you can program a series of checks and balances. Also, does the software support silent installation, so you don't have to mess with automating the GUI at all? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
junkew Posted October 26, 2015 Share Posted October 26, 2015 Its the hardest part to automate unexpected windows as you do not know if they come around and for how long. For example unexpected browser chats or advertisements overlay or suddenly credentials invalid. For more or less known popups with only ok button i just grab the text and put it in log as a warning and click ok automatically. If ok and cancel button i do the same in the assumption ok is most logical. If winexists('*') is a little.tricky but could work if your windows are having a certain regexclass.and use then a regex to match. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted October 26, 2015 Share Posted October 26, 2015 and an example to filter on a regular expression assuming you know the unexpected windows and the expected window. When either of them is found it should continue otherwise wait for timeoutExample() Func Example() ; Retrieve a list of window handles. ;Assume max times is 10 times for $x=1 to 10 Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable. Local $aList = WinList("(Error Installing)|(expected windowtitle)") Local $fDiff = TimerDiff($hTimer) ; Find the difference in time from the previous call of TimerInit. The variable we stored the TimerInit handlem is passed as the "handle" to TimerDiff. consolewrite($fDiff & " - windows found:" & $aList[0][0] & @CRLF) ; Loop through the array displaying only visable windows with a title. And jump out if $aList[0][0] > 0 Then For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then consolewrite("Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1]) EndIf Next ExitLoop EndIf ;sleep 1 second sleep(1000) Next EndFunc ;==>Example FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted October 26, 2015 Share Posted October 26, 2015 Adlibregister()Pretty much made for the situation you are inCreate a function to look for that window and close it and then you will not need to influence the rest of your install script with any blocking functions or waits. 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