auggs Posted October 13, 2015 Share Posted October 13, 2015 Welcome to my first post! (albeit for help but a first post nonetheless...)Im hoping to automate the installation of a program with the following script. The script works up until the second ControlClick.The first ControlClick works, clicks on the Accept button and then the installation process stops; the second ControlClick should click on the Install button but does not.expandcollapse popup#include <WinAPI.au3> #include <MsgBoxConstants.au3> #RequireAdmin AutoItSetOption('MouseCoordMode', 0) InstallXerox() ; ========================================================================= ; InstallXerox ; ========================================================================= Func InstallXerox() Local $PID = ShellExecute(@ScriptDir & '\VRMR-Applications\Core' & '\Xerox-5335-WC5325-5335-523050-PCL6-x64') $hWnd = _GetHwndFromPID($PID) If WinExists($hWnd, "") Then # This controlclick works ControlClick($hWnd, '', "[CLASS:Button; TEXT:Accept; INSTANCE:1]") Sleep(1000) # This controlclick does not ControlClick($hWnd, '', "[CLASS:Button; TEXT:Install; INSTANCE:2]") ; WinClose($hWnd) Else MsgBox($MB_SYSTEMMODAL, "Not found", "Windows does not exist") EndIf EndFunc ;END of InstallXerox Func _GetHwndFromPID($PID) $hWnd = 0 $stPID = DllStructCreate("int") Do $winlist2 = WinList() For $i = 1 To $winlist2[0][0] If $winlist2[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1] ExitLoop EndIf EndIf Next Sleep(100) Until $hWnd <> 0 Return $hWnd EndFunc ;==>_GetHwndFromPIDThanks in advance... Link to comment Share on other sites More sharing options...
water Posted October 13, 2015 Share Posted October 13, 2015 Welcome to AutoIt and the forum!Doesn't the installation routine provide a silent installation option? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
auggs Posted October 14, 2015 Author Share Posted October 14, 2015 Possible water...Curious why you are pointing me in this direction instead of working the problem...Thanks. Link to comment Share on other sites More sharing options...
Bert Posted October 14, 2015 Share Posted October 14, 2015 What Water is suggesting is have you looked to see if the installer supports command line switches. If yes, then that makes your project MUCH simpler. When using command line switches, you can do the entire install by the following example: "c:\nameofapp\setup.exe /q"What this will do is run the install without any windows being presented and the app is installed using default settings. Now depending on what command line switches are supported you may be able to use a setup file to control setting while the setup in performed. if you have this functionality it really makes things customizable as well as keeps your install stable. There is nothing more annoying than having an install fail due to a user mucking up the thing.Note: To find out what the support switches are, run the setup exe with the /? switch from a dos prompt. If you don't get anything then the app doesn't support it. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
auggs Posted October 14, 2015 Author Share Posted October 14, 2015 Unfortunately the company I work for produces diagnostic applications and none of the software supports silent installs.There are hundreds of types and several versions/updates of each type so I was hoping to make use of AutoIT for this purpose.I appreciate the advice but I don't have the luxury. I guess what I was asking of water is....am I headed for disappointment anyway. Link to comment Share on other sites More sharing options...
jdelaney Posted October 16, 2015 Share Posted October 16, 2015 (edited) You are probably including too many params in the control click for the button identification. Try it like this:ControlClick($hWnd, '', "[CLASS:Button; TEXT:Install]")I highly doubt there are 2 instances of a button with the text Install on your app.Also, is there any underlines in the Text? If so, you must include an & prior to the character that's underlined, like &Install if the I is underlined.Send us the AutoIT Window Info 'Summary' tab info, while focused on the install button if my suggestion doesn't help. Edited October 16, 2015 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...
auggs Posted October 20, 2015 Author Share Posted October 20, 2015 Thanks jdelaney. Tried your first suggestion as well as adding the ampersand but neither worked.There are not two instances of a button with the text "Install" expandcollapse popup>>>> Window <<<< Title: Xerox Software Installation Class: #32770 Position: 215, 155 Size: 527, 392 Style: 0x94CA08C4 ExStyle: 0x00010101 Handle: 0x00000000000A074C >>>> Control <<<< Class: Button Instance: 2 ClassnameNN: Button2 Name: Advanced (Class): [CLASS:Button; INSTANCE:2] ID: 1 Text: Install Position: 317, 336 Size: 90, 23 ControlClick Coords: 45, 11 Style: 0x50010000 ExStyle: 0x00000004 Handle: 0x00000000000107BC >>>> Mouse <<<< Position: 580, 527 Cursor ID: 0 Color: 0x32327D >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< &Destination folder C:\Xerox C:\Xerox Bro&wse... Installation progress Install Cancel >>>> Hidden Text <<<<Thanks. Link to comment Share on other sites More sharing options...
jdelaney Posted October 20, 2015 Share Posted October 20, 2015 (edited) No, there are not two instances of a button with text = Install. what that output is stating, is your button is the second instance of any button on your window...and that second instance of a button happens to have text=Install...note that there is no underscore, so no ampersand is required.It could be that the prior button click opens a window...if you use controlclick in such instances, your script will be frozen waiting for the return from the gui. This occurs when you manually close the window. If that's the case, you can instead controlsend "{enter}" at your first button, which doesn't wait for a return from the gui.If you are still stuck...my signature can output all the controls on your window...get that, and post it back. Maybe I can help you after that. Else, you need to be extremely specific about what's not working. Edited October 21, 2015 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...
Bert Posted October 21, 2015 Share Posted October 21, 2015 Unfortunately the company I work for produces diagnostic applications and none of the software supports silent installs.There are hundreds of types and several versions/updates of each type so I was hoping to make use of AutoIT for this purpose.I appreciate the advice but I don't have the luxury. I guess what I was asking of water is....am I headed for disappointment anyway.There is a option for you. It is a piece of work on your part however once you do it then deployment is easy. Basically you are "repackaging" the software. Once you repackage you can then use the silent install option. Take a look at the links and it will steer you on the right path. https://community.spiceworks.com/topic/115161-free-repackaging-toolshttp://serverfault.com/questions/22313/what-is-the-best-free-tool-to-wrap-an-exe-into-a-msi The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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