Jump to content

Detect if the focus item is a button or check box


Recommended Posts

Detect if the focus item is a button or check box

Hello everyone.
My dears I have a problem
When I try to use
ControlGetFocus function
it  doesn't recognize the check  boxes.
The result is that the selector is a button
Although the specified is a check box
but I want a way to identify the check boxes.
Because I want to make a tool that helps screen readers users
I hope you have the solution.
Thank you in advance.

 

Link to comment
Share on other sites

button,checkbox,radiobutton,groupbox --> all these controls have the same ClassName "Button" and they differ only in STYLE.

So you have to check its STYLE by 

$Style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)

and test if it contains desired style ($BS_CHECKBOX) ...

Edited by Zedna
Link to comment
Share on other sites

Something like this:

$focus_classnn = ControlGetFocus("...", "...")
$focus_hwnd = ControlGetHandle("...", "...", "[ClassNN:" & $focus_classnn & "]")

If IsCheckBox($focus_hwnd) Then ...


Func IsCheckBox($ctrl_hwnd)
    $Style = _WinAPI_GetWindowLong($ctrl_hwnd, $GWL_STYLE)
    Return BitAnd($Style, $BS_CHECKBOX) = $BS_CHECKBOX
EndFunc

 

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
 Share

×
×
  • Create New...