davidsuger Posted October 22, 2013 Share Posted October 22, 2013 Hi, I try to create a unattended install script for CPU-Z ftp://ftp.cpuid.com/cpu-z/cpu-z_1.67-setup-en.exe But AutoIt unable to focus on the button when ControlClick ( "Setup - CPUID CPU-Z", "", "TNewButton2" ), I tied Send("!n") also didn't work. I get "Unable to focus on button" from below scripts. expandcollapse popup; Get window handle $hUpgradeWin = WinGetHandle ( "[CLASS:TWizardForm; TITLE:Setup - CPUID CPU-Z]" ) If Not IsHWnd ( $hUpgradeWin ) Then $bContinue = False MsgBox ( 1,1,"Unable to get window Handle") Else $bContinue = True EndIf ; Activate window handle If $bContinue Then If Not IsHWnd ( WinActivate ( $hUpgradeWin ) ) Then $bContinue = False MsgBox ( 1,1, "Unable to activate window") EndIf EndIf ; Get control handle If $bContinue Then $hUpdateBtn = ControlGetHandle ( $hUpgradeWin, "", "[CLASS:TNewButton; TEXT:Cancel]" ) If Not IsHWnd ( $hUpdateBtn ) Then $bContinue = False MsgBox ( 1,1,"Unable to get button Handle") EndIf EndIf ; Focus on button ( I notice sometimes the click fails when skipping this step ) If $bContinue Then If Not ControlFocus ( $hUpgradeWin, "", $hUpdateBtn ) Then $bContinue = False MsgBox ( 1,1,"Unable to focus on button") EndIf EndIf ; click button If $bContinue Then If Not ControlClick ( $hUpgradeWin, "", $hUpdateBtn ) Then $bContinue = False MsgBox ( 1,1,"Unable to click button") EndIf EndIf I want to control this button, so any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
water Posted October 22, 2013 Share Posted October 22, 2013 Looks like CPU-Z supports a silent installation. So no need to click buttons etc. 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...
davidsuger Posted October 22, 2013 Author Share Posted October 22, 2013 Water, thanks for you reply. I am learning how to create install script. So AutoIt cannot interact with control like this? How to judge which control can interact or not? Link to comment Share on other sites More sharing options...
water Posted October 22, 2013 Share Posted October 22, 2013 AutoIt can interact with (most) controls. But we recommend to use a silent install if available. To get the ControlID use the Windows Info Tool that comes with AutoIt and then pass the ID to the ControlClick function. 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...
Starstar Posted October 22, 2013 Share Posted October 22, 2013 (edited) try this $hUpdateBtn = ControlGetHandle ( $hUpgradeWin, "", "[CLASS:TNewButton; TEXT:&Cancel]") ;It will click on Cancel. ;or this $hUpdateBtn = ControlGetHandle ( $hUpgradeWin, "", "[CLASS:TNewButton; ID:?]"); Enter your button id number in the place of "?" question mark. ;instead of $hUpdateBtn = ControlGetHandle ( $hUpgradeWin, "", "[CLASS:TNewButton; TEXT:Cancel]") Tell me please. what happened? Edited October 22, 2013 by adnanbaloch Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." 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