Couple of days ago i posted a forum question about ControlGet,
unfortunately didn't get a response. I've done some more testing
on both XP and Vista, and on both OS'es i get the same behaviour.
Grabbing some other sample code which uses controlGet, I also
get anomalous behaviour, so I'm really suspicious there is a bug here.
Running 1.0.47.06
i'm writing some automation code to allow for automatic testing of
a audio control matrix, so its a windows app with a field of checkboxes
which corresponds to a set of crosspoints in a switching matrix.
Nothing special.
The idea of the AHK code snippet below is that if a particular
checkbox is set, we flip it to the opposite state.
If its is -not- set, we flip the adjacent checkbox.
The problem is, no matter the state of Control app4227,
the adjacent checkbox is -always- set:
that is: the ControlGet call is -always- setting
currStateofButton to 0, it never gets set to one,
irrespective of whether the control app4227 has a checkbox set or unset.
I know that the correct control is being used for the activity
because the ControlClick properly addresses
the control, and flips the state of the checkbox back and forth
reliably. (if I do a loop, and don't bother with ControlGet
I can flip the control back and forth at will)
Code:
SetTitleMatchMode,2
IfWinExist, iCONMASTER
{
WinActivate ; Automatically uses the window found above.
}Else{
msgbox, "You Don't Have ICU open"
}
;;WindowsForms10.BUTTON.app4227
;; In case we needed focus on the Control,
;; this appeared to be used frequently in nDroid code
ControlFocus, WindowsForms10.BUTTON.app4227, iCONMASTER
;; use ControlGet to get the state of the chosen checkbox
ControlGet, currStateofButton, Checked, , WindowsForms10.BUTTON.app4227, iCONMASTER
;; If the checkbox is set (currStateofButton) is 1, use controlclick
;; to invert it
;; otherwise flip the adjacent checkbox
if currStateofButton
ControlClick, WindowsForms10.BUTTON.app4227, iCONMASTER,,LEFT,1
else
ControlClick, WindowsForms10.BUTTON.app4226, iCONMASTER,,LEFT,1
Is this a bug with ControlGet? I've tried every variation
with the window identifier, the spacing between the commas etc,
I've used MouseGetPos to identify the control instead, nothing.