Jump to content

getting checkbox state with UIAutomation

Recommended Posts

The target program I'm testing uses .NET, and so its checkboxes do not

respond to AutoIt's ControlCommand "IsChecked" request.

So I am trying use the UIAutomation stuff <CUIAutomation2.au3>

I can determine the button is a checkbox, but when I ask for

the legacy automation state I get an anomaly.

    $s = $oel.GetCurrentPropertyValue( _
        $UIA_LegacyIAccessibleStatePropertyId, _
        $state _

$state gets a value of 0x01000008 when the button is unchecked,

and 0x01000108 when unchecked.  All fine and good enough for

my purposes.  However, INSPECT.EXE reports the values as

0x00100014 and 0x00100004. 

<oleacc.h> gives





       0x00100000 STATE_SYSTEM_FOCUSABLE


Any idea why I get the bits in a different order?

Link to comment
Share on other sites

When you use Inspect the target window and control usually have focus. Are you sure that the target window and control had focus, when you run that piece of code. If not the values of $UIA_LegacyIAccessibleStatePropertyId are not comparable.

You should use the Spy tool to compare the values from the UI Automation framework with the values from Inspect. Then it's possible to compare the values under the same assumptions. I've done a few tests. I get the same values.

(I have changed UIAWrappers.au3 to print a hex value for $UIA_LegacyIAccessibleStatePropertyId.)

Link to comment
Share on other sites

Obviously, I don't quite know what I'm doing.

However, I changed my testing to programatically

move the mouse pointer and play with Inspect,

and now I do get agreement between the legacy state

I find and what Inspect reports.

   I manually turned on "Watch Cursor" then had the


     activated the target

     moved the mouse over the button

     paused for 3 seconds                  <-- to let Inspect read things

     Read and displayed the legacy status

     turned off "watch cursor"

The state I read did tell me "checked" properly.


Two more questions:

  What SPY program were you refering to?

  Where do I find the updated UIAWrappers.au3?

  The one I have is from an attachment in another

  forum thread, and is likely outdated

Link to comment
Share on other sites

The Spy program in the middle of the first post in the UI Automation framework.

This program uses UIAWrappers.au3, which you can download in the bottom of first post. In my personal version of this UDF I have change a few things. E.g. the output of $UIA_LegacyIAccessibleStatePropertyId from decimal to hex.

Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...