comc49 Posted June 24, 2013 Share Posted June 24, 2013 Hi I am trying to install an update through autoit script and during install there will be 4-6 error messages and I need to click "ok" through all of them. My boss tells me that every new update will bring more error messages so I want to create a loop that clicks through all the error messages. I am really new to autoit so is there any tips? Link to comment Share on other sites More sharing options...
jdelaney Posted June 24, 2013 Share Posted June 24, 2013 (edited) You can add all the possible titles to an array, and loop through this function: _WinAPI_GetWindow($parentHWND, 6) it grabs the enabled popup (windows spawned by the parent)...then grab the title of that window, and conditionally act on it based which window it is. something like: #include <WinAPI.au3> While ProcessExists("installer process") $hPopup = _WinAPI_GetWindow($parentHWND, 6) If $hPopup > 0 Then $sTitle = WinGetTitle($hPopup) ConsoleWrite($sTitle & @CRLF) ; perform action on popup EndIf WEnd If all are OK or &OK then this would probably work expandcollapse popup#include <WinAPI.au3> $iPid = Run("installer file") $parentHWND = "" $iCurrentPID = 0 Do $aWin = WinList() For $i = 0 To UBound($aWin)-1 _WinAPI_GetWindowThreadProcessId($aWin[$i][1], $iCurrentPID) If $iCurrentPID = $iPid Then $parentHWND = $aWin[$i][1] ExitLoop EndIf Next Until IsHWnd($parentHWND) While ProcessExists($iPid) $hPopup = _WinAPI_GetWindow($parentHWND, 6) If $hPopup > 0 Then $sTitle = WinGetTitle($hPopup) ConsoleWrite($sTitle & @CRLF) $hControl1 = ControlGetHandle($hPopup, "", "OK") $hControl2 = ControlGetHandle($hPopup, "", "&OK") If IsHWnd($hControl1) Then ControlFocus($hPopup, "", $hControl1) ControlClick($hPopup, "", $hControl1) ElseIf IsHWnd($hControl2) Then ControlFocus($hPopup, "", $hControl2) ControlClick($hPopup, "", $hControl2) Else MsgBox(1,1,"can't find an OK button...you will need to debug") Exit EndIf WinWaitClose($hPopup, "", 10) EndIf WEnd made some small changes Edited June 24, 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...
comc49 Posted June 24, 2013 Author Share Posted June 24, 2013 So that code will loop through all the installation titles? What does the number 6 represent? Link to comment Share on other sites More sharing options...
jdelaney Posted June 24, 2013 Share Posted June 24, 2013 (edited) number 6 represents returning the 'enabled popup' This script will spawn the process, get the parent window, and then continually loop until the process ends...clicking on popups that have button = "OK" or "&OK", and exiting if there is no such button (you will need to add logic if this is the case) from msdn: GW_ENABLEDPOPUP 6 The retrieved handle identifies the enabled popup window owned by the specified window (the search uses the first such window found using GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the retrieved handle is that of the specified window. Edited June 24, 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...
Moderators Melba23 Posted June 24, 2013 Moderators Share Posted June 24, 2013 jdelaney,guinness will have a fit if he sees you using "magic numbers" like that! M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
jdelaney Posted June 24, 2013 Share Posted June 24, 2013 the "6" needs to be added to the helpfile, and constants 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...
Moderators Melba23 Posted June 24, 2013 Moderators Share Posted June 24, 2013 jdelaney,But have you told him yet? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
jdelaney Posted June 24, 2013 Share Posted June 24, 2013 all set: 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...
comc49 Posted June 24, 2013 Author Share Posted June 24, 2013 Hm.. When I run the .exe created by the script, my powershell hangs.. Is there a way to run the .exe in the background? Link to comment Share on other sites More sharing options...
comc49 Posted June 24, 2013 Author Share Posted June 24, 2013 Can you run autoit script that automates install remotely? Link to comment Share on other sites More sharing options...
comc49 Posted June 24, 2013 Author Share Posted June 24, 2013 (edited) expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #region ---Au3Recorder generated code Start (v3.3.7.0) --- #region --- Internal functions Au3Recorder Start --- #requireadmin Run("\\xxx-fs-1.xxx.uxx.edu\software\npp.6.3.3.Installer.exe") WinWait("Installer Language","Please select a language") WinActivate("Installer Language","Please select a language") ControlClick("Installer Language","Please select a language",1) WinWait("Notepad++ v6.3.3 Setup","Welcome to the Notepad++ v6.3.3 Setup") WinActivate("Notepad++ v6.3.3 Setup","Welcome to the Notepad++ v6.3.3 Setup") ControlClick("Notepad++ v6.3.3 Setup","Welcome to the Notepad++ v6.3.3 Setup",1) WinWait("Notepad++ v6.3.3 Setup","License Agreement") WinActivate("Notepad++ v6.3.3 Setup","License Agreement") ControlClick("Notepad++ v6.3.3 Setup","License Agreement",1) WinWait("Notepad++ v6.3.3 Setup","Choose Install Location") WinActivate("Notepad++ v6.3.3 Setup","Choose Install Location") ControlClick("Notepad++ v6.3.3 Setup","Choose Install Location",1) WinWait("Notepad++ v6.3.3 Setup","Choose Components") WinActivate("Notepad++ v6.3.3 Setup","Choose Components") ControlClick("Notepad++ v6.3.3 Setup","Choose Components",1) WinWait("Notepad++ v6.3.3 Setup","Choose Components") WinActivate("Notepad++ v6.3.3 Setup","Install") ControlClick("Notepad++ v6.3.3 Setup","Install",1) WinWait("Notepad++ v6.3.3 Setup","Completing the Notepad++ v6.3.3 Setup") WinActivate("Notepad++ v6.3.3 Setup","Completing the Notepad++ v6.3.3 Setup") ControlClick("Notepad++ v6.3.3 Setup","Completing the Notepad++ v6.3.3 Setup",1203) ControlClick("Notepad++ v6.3.3 Setup","Completing the Notepad++ v6.3.3 Setup",1) Exit #endregion --- Au3Recorder generated code End --- Â This is my test code to install notepad++ remotely and it fails to install remotely.. Is there a better way to code this? Also is it possible to repackage the Installer file so that instead of having the installer.exe and the autoit script.exe I can have one .exe that can automatically install? Edited June 25, 2013 by comc49 Link to comment Share on other sites More sharing options...
comc49 Posted June 25, 2013 Author Share Posted June 25, 2013 (edited) Anyone? Is it possible to automate install remotely through powershell(powershell is just for connecting remotely and running the autoit compiled .exe)? Edited June 25, 2013 by comc49 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2013 Moderators Share Posted June 25, 2013 comc49,Please do not bump your own threads within 24 hours - and certainly not twice! Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
comc49 Posted June 26, 2013 Author Share Posted June 26, 2013 You can add all the possible titles to an array, and loop through this function: _WinAPI_GetWindow($parentHWND, 6) it grabs the enabled popup (windows spawned by the parent)...then grab the title of that window, and conditionally act on it based which window it is. something like: #include <WinAPI.au3> While ProcessExists("installer process") $hPopup = _WinAPI_GetWindow($parentHWND, 6) If $hPopup > 0 Then $sTitle = WinGetTitle($hPopup) ConsoleWrite($sTitle & @CRLF) ; perform action on popup EndIf WEnd If all are OK or &OK then this would probably work expandcollapse popup#include <WinAPI.au3> $iPid = Run("installer file") $parentHWND = "" $iCurrentPID = 0 Do $aWin = WinList() For $i = 0 To UBound($aWin)-1 _WinAPI_GetWindowThreadProcessId($aWin[$i][1], $iCurrentPID) If $iCurrentPID = $iPid Then $parentHWND = $aWin[$i][1] ExitLoop EndIf Next Until IsHWnd($parentHWND) While ProcessExists($iPid) $hPopup = _WinAPI_GetWindow($parentHWND, 6) If $hPopup > 0 Then $sTitle = WinGetTitle($hPopup) ConsoleWrite($sTitle & @CRLF) $hControl1 = ControlGetHandle($hPopup, "", "OK") $hControl2 = ControlGetHandle($hPopup, "", "&OK") If IsHWnd($hControl1) Then ControlFocus($hPopup, "", $hControl1) ControlClick($hPopup, "", $hControl1) ElseIf IsHWnd($hControl2) Then ControlFocus($hPopup, "", $hControl2) ControlClick($hPopup, "", $hControl2) Else MsgBox(1,1,"can't find an OK button...you will need to debug") Exit EndIf WinWaitClose($hPopup, "", 10) EndIf WEnd made some small changes  So I found out that I can't run the installer from autoit but I have to use psexec. Since I am using psexec to open the installer the autoit script can't access the PID of the installer.. Is there a way to pass in the pid or find the pid of the windows that are open? Link to comment Share on other sites More sharing options...
jdelaney Posted June 26, 2013 Share Posted June 26, 2013 (edited) Use psexec to excute the script you copy over to the station. Else, you need to find the parent handle through wingethandle (looped until you find it)...which wouldn't make sense, because then you would need to execute the installer and THEN the autoit script on the target station Edited June 26, 2013 by jdelaney comc49 1 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...
comc49 Posted June 27, 2013 Author Share Posted June 27, 2013 Thanks that works! Now I have to legit testing and see if I can update Link to comment Share on other sites More sharing options...
comc49 Posted July 1, 2013 Author Share Posted July 1, 2013 jdelaney your code only works for popups right? I think in my case its a new window everytime. Also the error messages happen in the middle of the installation so the while loop is going to run infinitely because the finish button won't get pressed 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