本帖最后由 虎虎虎 于 2012-8-22 15:56 编辑
如何通过选择单选框实现对复选框的选择,主要是互斥处理不好(个人比较笨,大家别笑我),为了避免混乱,我把代码清理了一下,如下:#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("优化工具", 530, 535, 204, 128)
GUICtrlCreateGroup("操作", 5, 456, 518, 49)
$Button1 = GUICtrlCreateButton("优化 (U)", 309, 471, 75, 25)
$Button2 = GUICtrlCreateButton("退出 (E)", 421, 471, 75, 25)
$Radio1 = GUICtrlCreateRadio("推荐", 21, 477, 73, 17)
$Radio2 = GUICtrlCreateRadio("全选", 101, 477, 65, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group1 = GUICtrlCreateGroup("右键优化", 6, 104, 513, 105)
GUICtrlCreateCheckbox("右键添加上帝模式菜单", 24, 128, 137, 17)
GUICtrlCreateCheckbox("右键添加记事本打开", 184, 128, 129, 17)
GUICtrlCreateCheckbox("右键加上复制到和移动到键", 344, 128, 161, 17)
GUICtrlCreateCheckbox("右键添加【服务项】", 24, 156, 121, 17)
GUICtrlCreateCheckbox("右键添加注册表编辑器", 184, 156, 137, 17)
GUICtrlCreateCheckbox("右键添加组策略", 344, 156, 113, 17)
GUICtrlCreateCheckbox("右键菜单添加控制面板", 24, 184, 137, 17)
GUICtrlCreateCheckbox("右键管理员取得所有权", 184, 184, 137, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("个性优化", 8, 216, 513, 105)
GUICtrlCreateCheckbox("在开始菜单显示运行", 24, 240, 129, 17)
GUICtrlCreateCheckbox("在桌面上显示计算机", 184, 240, 129, 17)
GUICtrlCreateCheckbox("在桌面上显示回收站", 344, 240, 129, 17)
GUICtrlCreateCheckbox("在桌面上显示个人文件夹", 24, 268, 153, 17)
GUICtrlCreateCheckbox("在桌面上显示控制面板", 184, 268, 137, 17)
GUICtrlCreateCheckbox("在桌面显示网络", 344, 268, 105, 17)
GUICtrlCreateCheckbox("win7显示桌面IE图标(x86)", 24, 296, 153, 17)
GUICtrlCreateCheckbox("修改默认安装目录为D盘", 184, 296, 145, 17)
GUICtrlCreateCheckbox("关闭程序兼容性助手", 344, 296, 129, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("任务栏优化", 9, 328, 513, 105)
GUICtrlCreateCheckbox("隐藏操作中心托盘图标", 24, 360, 137, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
基本解决,不知哪位有更好的法子。。 特别是匹配【推荐】;如果选项过多,一项一项的设置,太没效率了。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1) ;启用/关闭 OnEvent 函数通知。0 = (默认),取消 1 = 启用。
;~ AutoItSetOption /opt(调整 AutoIt 各种函数/参数的运作方式.)。
Global $Form1_1
_main()
Func _main()
$Form1_1 = GUICreate("优化工具", 530, 535, 204, 128)
GUICtrlCreateGroup("操作", 5, 456, 518, 49)
Global $Button1 = GUICtrlCreateButton("优化 (&U)", 309, 471, 75, 25)
Global $Button2 = GUICtrlCreateButton("退出 (&E)", 421, 471, 75, 25)
Global $TJ = GUICtrlCreateRadio("推荐", 21, 477, 73, 17)
;GUICtrlSetState(-1, $GUI_CHECKED)
Global $QX = GUICtrlCreateRadio("全选", 101, 477, 65, 17)
Global $Checkbox[19]
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group1 = GUICtrlCreateGroup("右键优化", 6, 104, 513, 105)
$Checkbox[1] = GUICtrlCreateCheckbox("右键添加上帝模式菜单", 24, 128, 137, 17)
$Checkbox[2] = GUICtrlCreateCheckbox("右键添加记事本打开", 184, 128, 129, 17)
$Checkbox[3] = GUICtrlCreateCheckbox("右键加上复制到和移动到键", 344, 128, 161, 17)
$Checkbox[4] = GUICtrlCreateCheckbox("右键添加【服务项】", 24, 156, 121, 17)
$Checkbox[5] = GUICtrlCreateCheckbox("右键添加注册表编辑器", 184, 156, 137, 17)
$Checkbox[6] = GUICtrlCreateCheckbox("右键添加组策略", 344, 156, 113, 17)
$Checkbox[7] = GUICtrlCreateCheckbox("右键菜单添加控制面板", 24, 184, 137, 17)
$Checkbox[8] = GUICtrlCreateCheckbox("右键管理员取得所有权", 184, 184, 137, 17)
$Group2 = GUICtrlCreateGroup("个性优化", 8, 216, 513, 105)
$Checkbox[9] = GUICtrlCreateCheckbox("在开始菜单显示运行", 24, 240, 129, 17)
$Checkbox[10] = GUICtrlCreateCheckbox("在桌面上显示计算机", 184, 240, 129, 17)
$Checkbox[11] = GUICtrlCreateCheckbox("在桌面上显示回收站", 344, 240, 129, 17)
$Checkbox[12] = GUICtrlCreateCheckbox("在桌面上显示个人文件夹", 24, 268, 153, 17)
$Checkbox[13] = GUICtrlCreateCheckbox("在桌面上显示控制面板", 184, 268, 137, 17)
$Checkbox[14] = GUICtrlCreateCheckbox("在桌面显示网络", 344, 268, 105, 17)
$Checkbox[15] = GUICtrlCreateCheckbox("win7显示桌面IE图标(x86)", 24, 296, 153, 17)
$Checkbox[16] = GUICtrlCreateCheckbox("修改默认安装目录为D盘", 184, 296, 145, 17)
$Checkbox[17] = GUICtrlCreateCheckbox("关闭程序兼容性助手", 344, 296, 129, 17)
$Group3 = GUICtrlCreateGroup("任务栏优化", 9, 328, 513, 105)
$Checkbox[18] = GUICtrlCreateCheckbox("隐藏操作中心托盘图标", 24, 360, 137, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
EndFunc ;==>_main
#endregion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ;当一个系统按钮被点击时调用一个用户自定义函数(UDF).
GUICtrlSetOnEvent($Button1, "_run")
GUICtrlSetOnEvent($Button2, "_exit");为指定控件的点击行为定义一个用户函数.
GUICtrlSetOnEvent($TJ, "_choose");推荐用户选择项目
GUICtrlSetOnEvent($QX, "_all");全选用户选择项目
While 1
Sleep(1000)
WEnd
Func _exit()
Exit
EndFunc ;==>_exit
Func _choose() ;推荐项目。
For $Gi = 1 To 18
GUICtrlSetState($Checkbox[$Gi], 4)
Next
;Dim $Hi[6]= [2,3,4,5,6,7]
GUICtrlSetState($Checkbox[2], 1)
GUICtrlSetState($Checkbox[3], 1)
GUICtrlSetState($Checkbox[4], 1)
GUICtrlSetState($Checkbox[6], 1)
GUICtrlSetState($Checkbox[9], 1)
GUICtrlSetState($Checkbox[17], 1)
GUICtrlSetState($Checkbox[18], 1)
EndFunc ;==>_choose
Func _all() ;全部项目。
For $Gi = 1 To 18
GUICtrlSetState($Checkbox[$Gi], 1)
Next
EndFunc ;==>_all
Func _run()
Switch MsgBox(64, "测试", "先测试,再说。。", 0)
Case 1
EndSwitch
EndFunc ;==>_run
|