Click button, or get checked state

Syntax1 - click, check, etc

but[+|-|*|%] hwndbutton

 

Syntax2 - click, check, etc

but[+|-|*|%] id|text window

 

Syntax3 - get checked state

int but(hwndbutton)

 

Syntax4 - get checked state

int but(id|text window)

 

Parts

hwndbutton - button handle. To get button handle, use function id or child.

window - top-level parent window. The function searches only in the first found matching window.

id - button id.

text - button label. Can be partial, but from beginning. Underlined characters must be preceded with &. The window must not have other controls with the same text.

Options: + check checkbox; - uncheck checkbox; * toggle checkbox; % click if unchecked; default: click.

 

Remarks

Syntax1 and 2

Clicks, checks or unchecks button, check box or radio button.

 

Option characters usually are used with check boxes, and should not be used with radio buttons. Option + also can be used with push buttons.

 

May not work if the window is inactive, unless option character +, - or * is used.

 

Syntax3 and 4

Returns check state of check box or radio (option) button. Return value: 0 - unchecked, 1 - checked, 2 indeterminate.

 

Examples

but child(100 100 "Calc") ;;click button at 100 100 of "Calc" window
but id(306 "Calc") ;;click button with id=306 on window "Calc"
but+ 306 "Calc" ;;check check-button with id=306 on window "Calc"
but "&Open" "Open" ;;click button "Open" on window "Open"

 If radio button "Down" in "Find" dialog is unchecked, click it:
int h=child("&Down" "Button" "Find")
if(!but(h)) but h