auggs

ControlClick Works Only Once

9 posts in this topic

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.

#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 ;==>_GetHwndFromPID

Thanks in advance...

Share this post


Link to post
Share on other sites



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 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Possible water...

Curious why you are pointing me in this direction instead of working the problem...

Thanks.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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" :)

>>>> 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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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-tools

http://serverfault.com/questions/22313/what-is-the-best-free-tool-to-wrap-an-exe-into-a-msi

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now