Jump to content
Sign in to follow this  
mraymond

Reading the state of a checkbox with GUICtrlRead

Recommended Posts

I've been trying for a while to get the state of a check box in an existing application. Finally found the GUICtrlRead function but have not been able to figure out the right way to use it. I've tried examples of other peoples work here in the forums, but no matter what I do, it always returns a zero. This returns a zero whether I have the box checked or unchecked, so I know it's not giving me the correct information. Below is the code, and then the autoit control viewer information.

; -------------------------------------------------------------------------------------------------

; Verify the Application Preference Startup File: check box is defaulted as unchecked

; -------------------------------------------------------------------------------------------------

_FileWriteLog( "Script_Log.txt", "--------------------------------------------------------------------------------------------------" )

_FileWriteLog( "Script_Log.txt", "-- Verifying Application Preferences Startup File: check box is defaulted as unchecked" )

_FileWriteLog( "Script_Log.txt", "--------------------------------------------------------------------------------------------------" )

ControlFocus("Application Preferences", "", "Button32")

$state = GUICtrlRead ( "[CLASS:Button, Instance 32]" )

_FileWriteLog( "Script_Log.txt", $state )

--------------- viewer information

Class Button

Instance 32

ClassnameNN Button32

ID 2363

Text &Startup File:

Positioin 20, 10

Size 99, 16

ControlClick Coords 8, 8

Style 0x50010003

ExStyle 0x00000004

Handle 0x006204D6

Share this post


Link to post
Share on other sites

ControlCommand

Cool! That was easy. It worked. Below is the code I used to fix it. Thank you... that was great!

ControlFocus("Application Preferences", "", "Button32")

$State = ControlCommand ( "Application Preferences", "&Startup File:", "[CLASSNN:Button32]", "IsChecked", "" )

_FileWriteLog( "Script_Log.txt", $state )

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
Sign in to follow this  

×
×
  • Create New...