找回密码
 加入
搜索
查看: 3323|回复: 3

[AU3基础] 请问怎样设置5个单选框的值,并获取其值写入注册表

[复制链接]
发表于 2010-9-12 23:19:33 | 显示全部楼层 |阅读模式

5个单选框的意思是:
选择“非强制登录”,写入注册表的值是2,
选择强制登录,写入注册表值是1
选择标准登录,写入注册值是0
以上三个是同一个变量,如果选择了上面三个中的一个,
下面变量的值就会写成0,。
下面两个是同一个变量,如果选择了下面两个中的一个,
上面变量的值就会写成0,。
非域自动登录,写入注册表值是0
选择域自动登录,写入注册表值是1
请哪位大侠指点一下,我弄了很长时间,就是没有做出来?(新手)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-9-13 00:10:00 | 显示全部楼层
回复 1# zymovie
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
        Local $radio1, $radio2, $radio3, $radio4, $radio5, $msg
        GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered

        $radio1 = GUICtrlCreateRadio("非域自动登录", 10, 10, 120, 20)
        $radio2 = GUICtrlCreateRadio("域自动登录", 10, 40, 120, 20)
        $radio3 = GUICtrlCreateRadio("标准登录", 10, 70, 120, 20)
        $radio4 = GUICtrlCreateRadio("非强制登录", 10, 100, 120, 20)
        $radio5 = GUICtrlCreateRadio("强制登录", 10, 130, 120, 20)

        GUISetState() ; will display an  dialog box with 1 checkbox

        ; Run the GUI until the dialog is closed
        While 1
                $msg = GUIGetMsg()
                Select
                        Case $msg = $GUI_EVENT_CLOSE
                                ExitLoop
                        Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "0")
                        Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "1")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "0")
                        Case $msg = $radio3 And BitAND(GUICtrlRead($radio3), $GUI_CHECKED) = $GUI_CHECKED
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "0")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                        Case $msg = $radio4 And BitAND(GUICtrlRead($radio4), $GUI_CHECKED) = $GUI_CHECKED
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "2")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                        Case $msg = $radio5 And BitAND(GUICtrlRead($radio5), $GUI_CHECKED) = $GUI_CHECKED
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "1")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                EndSelect
        WEnd
EndFunc   ;==>Example

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-9-13 22:25:45 | 显示全部楼层
本帖最后由 zymovie 于 2010-9-13 22:30 编辑

非常感谢李小龙的回答!
我要的是这种效果,可否帮我修改一下,谢谢:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiIPAddress.au3>
#include <ACN_NET.au3>
$Form1 = GUICreate("Client脚本添加工具", 370, 356, 196, 133)
GUISetIcon("1.ICO", -1)
$Label1 = GUICtrlCreateLabel("服务器IP地址:", 24, 16, 122, 17)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 152, 16, 185, 25, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
_GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
$Label2 = GUICtrlCreateLabel("域服务器IP地址:", 48, 56, 98, 17) ;能自动获取最好
$IPAddress2 = _GUICtrlIpAddress_Create($Form1, 152, 56, 185, 25, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
_GUICtrlIpAddress_Set($IPAddress2, "0.0.0.0")
$Label3 = GUICtrlCreateLabel("域服务器域名:", 56, 96, 88, 17);能自动获取最好
$Input1 = GUICtrlCreateInput("Input1", 152, 96, 185, 21, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Label4 = GUICtrlCreateLabel("客户端MAC:", 64, 136, 75, 17)
$Input2 = GUICtrlCreateInput("Input2", 152, 136, 185, 21, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Group1 = GUICtrlCreateGroup("登录方式", 24, 168, 321, 105)
$Radio1 = GUICtrlCreateRadio("非域自动登录", 48, 200, 97, 17, BitOR($GUI_SS_DEFAULT_RADIO,$BS_RIGHT))
$Radio2 = GUICtrlCreateRadio("域自动登录", 208, 200, 81, 17, BitOR($GUI_SS_DEFAULT_RADIO,$BS_RIGHT))
$Radio3 = GUICtrlCreateRadio("标准登录", 48, 232, 73, 17, BitOR($GUI_SS_DEFAULT_RADIO,$BS_RIGHT))
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio4 = GUICtrlCreateRadio("非强制登录", 144, 232, 89, 17, BitOR($GUI_SS_DEFAULT_RADIO,$BS_RIGHT))
$Radio5 = GUICtrlCreateRadio("强制登录", 248, 232, 81, 17, BitOR($GUI_SS_DEFAULT_RADIO,$BS_RIGHT))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("运行", 16, 296, 89, 25)
$Button2 = GUICtrlCreateButton("退出", 256, 296, 89, 25)
$Button3 = GUICtrlCreateButton("配置文件", 136, 296, 89, 25);可以通过配置文件导入和导出,填写上面的内容和保存上述内容
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;用户代码
Dim $ADDN,$SType,$MAC,$WSSType
$SWWIP = _GUICtrlIpAddress_Get($IPAddress1)
$ADIP = _GUICtrlIpAddress_Get($IPAddress2)
$MAC = _API_Get_NetworkAdapterMAC(@IPAddress1);获取mac地址
GUICtrlSetData($Input2,$MAC) ;回值给Input2
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button2
                        Exit
                Case $Button1
                        $ADDN = GUICtrlRead($Input1);获取input控件中输入的信息
                       
                        ;32位系统注册表键值
                        RegWrite("HKLM\SOFTWARE\test","SrvIP","REG_SZ",$SWWIP)
                        RegWrite("HKLM\SOFTWARE\test","DomainSrvIP","REG_SZ",$ADIP)
                        RegWrite("HKLM\SOFTWARE\test","SrvPORT","REG_SZ","2222")
                        RegWrite("HKLM\SOFTWARE\test","DomainName","REG_SZ",$ADDN)
                        RegWrite("HKLM\SOFTWARE\test","StartupType","REG_DWORD",$SType)
                        RegWrite("HKLM\SOFTWARE\test","ValidMac","REG_SZ",$MAC)
                        RegWrite("HKLM\SOFTWARE\test","WorkstationStartupType","REG_DWORD",$WSSType)
                        ;64位系统注册表键值
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","SrvIP","REG_SZ",$SWWIP)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","DomainSrvIP","REG_SZ",$ADIP)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","SrvPORT","REG_SZ","2222")
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","DomainName","REG_SZ",$ADDN)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","StartupType","REG_DWORD",$SType)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","ValidMac","REG_SZ",$MAC)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test","WorkstationStartupType","REG_DWORD",$WSSType)
                        MsgBox(0,"提示...","添加成功...")
        EndSwitch
WEnd
发表于 2010-9-13 23:15:52 | 显示全部楼层
回复 3# zymovie

使用 If, ElseIf
GUICtrlRead 读取指定控件的状态或相关数据.
$GUI_CHECKED 单选按框钮(Radio)将被选中
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <ACN_NET.au3>
$Form1 = GUICreate("Client脚本添加工具", 370, 356, 196, 133)
GUISetIcon("1.ICO", -1)
$Label1 = GUICtrlCreateLabel("服务器IP地址:", 24, 16, 122, 17)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 152, 16, 185, 25, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
_GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
$Label2 = GUICtrlCreateLabel("域服务器IP地址:", 48, 56, 98, 17) ;能自动获取最好
$IPAddress2 = _GUICtrlIpAddress_Create($Form1, 152, 56, 185, 25, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
_GUICtrlIpAddress_Set($IPAddress2, "0.0.0.0")
$Label3 = GUICtrlCreateLabel("域服务器域名:", 56, 96, 88, 17);能自动获取最好
$Input1 = GUICtrlCreateInput("Input1", 152, 96, 185, 21, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
$Label4 = GUICtrlCreateLabel("客户端MAC:", 64, 136, 75, 17)
$Input2 = GUICtrlCreateInput("Input2", 152, 136, 185, 21, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
$Group1 = GUICtrlCreateGroup("登录方式", 24, 168, 321, 105)
$Radio1 = GUICtrlCreateRadio("非域自动登录", 48, 200, 97, 17, BitOR($GUI_SS_DEFAULT_RADIO, $BS_RIGHT))
$Radio2 = GUICtrlCreateRadio("域自动登录", 208, 200, 81, 17, BitOR($GUI_SS_DEFAULT_RADIO, $BS_RIGHT))
$Radio3 = GUICtrlCreateRadio("标准登录", 48, 232, 73, 17, BitOR($GUI_SS_DEFAULT_RADIO, $BS_RIGHT))
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio4 = GUICtrlCreateRadio("非强制登录", 144, 232, 89, 17, BitOR($GUI_SS_DEFAULT_RADIO, $BS_RIGHT))
$Radio5 = GUICtrlCreateRadio("强制登录", 248, 232, 81, 17, BitOR($GUI_SS_DEFAULT_RADIO, $BS_RIGHT))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("运行", 16, 296, 89, 25)
$Button2 = GUICtrlCreateButton("退出", 256, 296, 89, 25)
$Button3 = GUICtrlCreateButton("配置文件", 136, 296, 89, 25);可以通过配置文件导入和导出,填写上面的内容和保存上述内容
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;用户代码
Dim $ADDN, $SType, $MAC, $WSSType
$SWWIP = _GUICtrlIpAddress_Get($IPAddress1)
$ADIP = _GUICtrlIpAddress_Get($IPAddress2)
$MAC = _API_Get_NetworkAdapterMAC(@IPAddress1);获取mac地址
GUICtrlSetData($Input2, $MAC) ;回值给Input2
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button2
                        Exit
                Case $Button1
                        $ADDN = GUICtrlRead($Input1);获取input控件中输入的信息

                        ;32位系统注册表键值
                        RegWrite("HKLM\SOFTWARE\test", "SrvIP", "REG_SZ", $SWWIP)
                        RegWrite("HKLM\SOFTWARE\test", "DomainSrvIP", "REG_SZ", $ADIP)
                        RegWrite("HKLM\SOFTWARE\test", "SrvPORT", "REG_SZ", "2222")
                        RegWrite("HKLM\SOFTWARE\test", "DomainName", "REG_SZ", $ADDN)
                        RegWrite("HKLM\SOFTWARE\test", "StartupType", "REG_DWORD", $SType)
                        RegWrite("HKLM\SOFTWARE\test", "ValidMac", "REG_SZ", $MAC)
                        RegWrite("HKLM\SOFTWARE\test", "WorkstationStartupType", "REG_DWORD", $WSSType)
                        ;64位系统注册表键值
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "SrvIP", "REG_SZ", $SWWIP)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "DomainSrvIP", "REG_SZ", $ADIP)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "SrvPORT", "REG_SZ", "2222")
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "DomainName", "REG_SZ", $ADDN)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "StartupType", "REG_DWORD", $SType)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "ValidMac", "REG_SZ", $MAC)
                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\test", "WorkstationStartupType", "REG_DWORD", $WSSType)

                        ;判断单选框状态
                        If GUICtrlRead($Radio1) = $GUI_CHECKED Then
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "0")
                        ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "1")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "0")
                        ElseIf GUICtrlRead($Radio3) = $GUI_CHECKED Then
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "0")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                        ElseIf GUICtrlRead($Radio4) = $GUI_CHECKED Then
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "2")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                        ElseIf GUICtrlRead($Radio5) = $GUI_CHECKED Then
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "1")
                                RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_MULTI_SZ", "0")
                        EndIf
                        MsgBox(0, "提示...", "添加成功...")
        EndSwitch
WEnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-14 16:11 , Processed in 0.084041 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表