Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

How can I get the current state of a checkbox on a window using Autoit script?

I am trying to set the value of a checkbox to be checked but I have not been able to figure out how to determine its current state using AutoIT. Any idea how I can pull this off?

Here is the data from the control:
>>>> Window <<<<
Title:      End Labor Activity
Class:      WindowsForms10.Window.8.app.0.2004eee
Position:      78, 16
Size:      758, 694
Style:      0x16CF0000
ExStyle:      0x00050100
Handle:      0x0000000001865096

>>>> Control <<<<
Class:      WindowsForms10.Window.8.app.0.2004eee
Instance:      40
ClassnameNN:      WindowsForms10.Window.8.app.0.2004eee40
Name:      chkComplete
Advanced (Class):      [NAME:chkComplete]
ID:      8267440
Text:      
Position:      167, 279
Size:      16, 17
ControlClick Coords:      4, 13
Style:      0x56010000
ExStyle:      0x00000000
Handle:      0x00000000007E26B0
Avatar of Bill Bach
Bill Bach
Flag of United States of America image

I see that nobody has yet posted a reply to this one.  I don't use AutoIt, but I use another tool called KeyText, and I have had to do the same thing, so perhaps this will give you the right idea:

KeyText supports a function called "If Pixel Color", which allows you to pick up the color of a specific pixel on the screen (relative to the screen, or relative to the dialog box it is running over) and make a decision based on that.  To ensure that a checkbox is checked, you would do an IfPixelColor call and if it matches the blank background color, you could then issue the mouse click to toggle it.

A quick web search shows that AutoIt has a function called PixelGetColor, so this should be easily doable there, too.
Avatar of Jeremy Campbell

ASKER

Thanks for that Bill, I will have a look into it and report back.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.