Autoit检查单复选框的选中状态
示例/演示
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)
Global $iMemo
_Main()
Func _Main()
Local $rdo, $rdo2, $chk
GUICreate("Buttons", 400, 400)
$iMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
$rdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)
$rdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
_GUICtrlButton_SetCheck($rdo2)
_GUICtrlButton_SetFocus($rdo2) ; set focus, shows this doesn't affect _GUICtrlButton_GetCheck
$chk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
_GUICtrlButton_SetCheck($chk, $BST_INDETERMINATE)
GUISetState()
MemoWrite("$rdo checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($rdo)) & @CRLF)
MemoWrite("$rdo2 checked status: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($rdo2)) & @CRLF) MemoWrite("$chk checked status.: " & @CRLF & @TAB &
_ExplainCheckState(_GUICtrlButton_GetCheck($chk)) & @CRLF)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Exitcheckbox和radiobutton的区别
EndFunc  ;==>_Main
; Write a line to the memo control
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc  ;==>MemoWrite
Func _ExplainCheckState($iState)
Switch $iState
Case $BST_CHECKED
Return "Button is checked."
Case $BST_INDETERMINATE
Return "Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style)."        Case $BST_UNCHECKED
Return "Button is cleared"
EndSwitch
EndFunc  ;==>_ExplainCheckState
函数参考
_GUICtrlButton_GetCheck
得到单选按钮或者复选框选中状态
#Include <GuiButton.au3>
_GUICtrlButton_GetCheck($hWnd)
参数
返回值
Success: The return value from a button created with the $BS_AUTOCHECKBOX, $BS_AUTORADIOBUTTON,
$BS_AUTO3STATE, $BS_CHECKBOX, $BS_RADIOBUTTON, or $BS_3STATE
style can be one of the following:
$BST_CHECKED - Button is checked.
$BST_INDETERMINATE - Button is grayed, indicating an
indeterminate state (applies only if the button has the
$BS_3STATE or $BS_AUTO3STATE style).
$BST_UNCHECKED Button is cleared
Failure: 0
注意/说明
If the button has a style other than those listed, the return value is zero.