botanycc 发表于 2008-5-9 20:24:43

哪位热心人能否帮我完成下这脚本

如图,在下边添加一个全选和取消全选的功能。谁能帮一下我,谢谢啊,我真不知道怎么弄弄了



#include <GUIConstants.au3>

$Form1 = GUICreate("例题", 356, 396, 333, 185)

$Group2 = GUICtrlCreateGroup("请您选择", 40, 102, 257, 65)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Checkbox1 = GUICtrlCreateCheckbox("计算器", 72, 118, 97, 17)
GUICtrlSetState ($Checkbox1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("画图", 72, 142, 97, 17)

$Button1 = GUICtrlCreateButton("马上运行", 48, 304, 209, 49, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
   ExitLoop
Case $msg=$Button1

    _res()
   
EndSelect

WEnd
Func _res()


   If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    run ("calc.exe","","")
   EndIf
   If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
    run ("mspaint.exe","","3")
   EndIf
EndFunc

[ 本帖最后由 botanycc 于 2008-5-9 21:22 编辑 ]

netegg 发表于 2008-5-9 21:14:14

$Checkbox3 = GUICtrlCreateCheckbox("全选", 72, 166, 97, 17)
GUICtrlSetState ($Checkbox3, $GUI_UNCHECKED)
Func _res()
   If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
   GUICtrlRead($Checkbox1) = $GUI_CHECKED
   GUICtrlRead($Checkbox2 ) = $GUI_CHECKED
   EndIf
EndFunc
不过可能需要把前面的1和2放到另外的函数内

[ 本帖最后由 netegg 于 2008-5-9 21:17 编辑 ]

sanhen 发表于 2008-5-9 21:16:47

#include <GUIConstants.au3>

$Form1 = GUICreate("例题", 356, 396, 333, 185)

$Group2 = GUICtrlCreateGroup("请您选择", 40, 102, 257, 65)
;GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Checkbox1 = GUICtrlCreateCheckbox("计算器", 72, 118, 97, 17)
GUICtrlSetState ($Checkbox1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("画图", 72, 142, 97, 17)

$Button1 = GUICtrlCreateButton("马上运行", 48, 304, 209, 49, 0)

$Check = GUICtrlCreateCheckbox("全选", 48, 200, 209, 60, 0)

;GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
   ExitLoop
Case $msg=$Button1

    _res()
Case $msg=$Check
   _Check()
EndSelect

WEnd

Func_Check()

$Choose=GUICtrlRead($Check )

Switch $Choose

        Case 1
             GUICtrlSetState ($Checkbox1, $GUI_CHECKED)
         GUICtrlSetState ($Checkbox2, $GUI_CHECKED)
    Case 4
      GUICtrlSetState ($Checkbox1, $GUI_UNCHECKED)
      GUICtrlSetState ($Checkbox2, $GUI_UNCHECKED)
EndSwitch

EndFunc

Func _res()


   If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    run ("calc.exe","","")
   EndIf
   If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
    run ("mspaint.exe","","3")
   EndIf
EndFunc

botanycc 发表于 2008-5-9 21:21:04

多谢楼上的,不过好像不行啊,点全选没反应

botanycc 发表于 2008-5-9 21:22:34

多谢管理员,还有二楼的,问题已经解决了

sanhen 发表于 2008-5-9 21:22:48

怎么个不行法?有什么提示不?
我在3.2.11.10下测试成功。
页: [1]
查看完整版本: 哪位热心人能否帮我完成下这脚本