找回密码
 加入
搜索
查看: 1487|回复: 6

求助~求助~求助!

[复制链接]
发表于 2009-6-1 20:29:24 | 显示全部楼层 |阅读模式
$reg = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
if RegRead($reg,"AutoAdminLogon") = 1 Then
        $jx = MsgBox(32+4,"提示","你已经设置了自动登陆,请问还要继续设置吗?")
        if $jx = 7 then exit
EndIf
$user = RegRead($reg,"DefaultUserName")
$PASS = RegRead($reg,"DefaultPassword")       
$NAME = InputBox("自动登陆","请输入用户名:",$user,"",250,100)
if $user = "" Then
        MsgBox(16,"提示","用户名不能为空!")
$PASSWORD = InputBox("自动登陆","请输入密码:",$PASS,"*",250,100)
        RegWrite($reg,"DefaultUserName","REG_SZ",$NAME)
        RegWrite($reg,"AutoAdminLogon","REG_SZ",1)
    RegWrite($reg,"DefaultPassword","REG_SZ",$PASSWORD)
        MsgBox(64,"提示","设置完成!")
EndIf

求助一个问题。上面的如果$user 输入了空的话,那么弹出提示, 用户名不能为空,然后确定了之后跳转到 请输入用户名那里($NAME),重新输入用户名!
 楼主| 发表于 2009-6-1 20:29:53 | 显示全部楼层
在线等~~~~谢谢了!
发表于 2009-6-1 20:33:58 | 显示全部楼层
利用循环。

$reg = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
If RegRead($reg, "AutoAdminLogon") = 1 Then
        $jx = MsgBox(32 + 4, "提示", "你已经设置了自动登陆,请问还要继续设置吗?")
        If $jx = 7 Then Exit
EndIf

Do
        $user = RegRead($reg, "DefaultUserName")
        $PASS = RegRead($reg, "DefaultPassword")
        $NAME = InputBox("自动登陆", "请输入用户名:", $user, "", 250, 100)
        If $NAME == "" Then
                MsgBox(16, "提示", "用户名不能为空!")
                ContinueLoop
        EndIf
Until 1

$PASSWORD = InputBox("自动登陆", "请输入密码:", $PASS, "*", 250, 100)
RegWrite($reg, "DefaultUserName", "REG_SZ", $NAME)
RegWrite($reg, "AutoAdminLogon", "REG_SZ", 1)
RegWrite($reg, "DefaultPassword", "REG_SZ", $PASSWORD)
MsgBox(64, "提示", "设置完成!")
 楼主| 发表于 2009-6-1 20:40:59 | 显示全部楼层
3# sensel


不行啊。输入为空,只提示 不能为空,之后就往下继续运行了!!
发表于 2009-6-1 20:52:34 | 显示全部楼层
抱歉,没经过测试就回答了。2楼代码严重错误。

$reg = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
If RegRead($reg, "AutoAdminLogon") = 1 Then
        $jx = MsgBox(32 + 4, "提示", "你已经设置了自动登陆,请问还要继续设置吗?")
        If $jx = 7 Then Exit
EndIf

While 1
        $user = RegRead($reg, "DefaultUserName")
        $PASS = RegRead($reg, "DefaultPassword")
        $NAME = InputBox("自动登陆", "请输入用户名:", $user, "", 250, 100)
        If $NAME == "" Then
                MsgBox(16, "提示", "用户名不能为空!")
        Else
                ExitLoop
        EndIf
WEnd

$PASSWORD = InputBox("自动登陆", "请输入密码:", $PASS, "*", 250, 100)
RegWrite($reg, "DefaultUserName", "REG_SZ", $NAME)
RegWrite($reg, "AutoAdminLogon", "REG_SZ", 1)
RegWrite($reg, "DefaultPassword", "REG_SZ", $PASSWORD)
MsgBox(64, "提示", "设置完成!")
 楼主| 发表于 2009-6-1 21:03:28 | 显示全部楼层
4楼的正解,多谢多谢了!
还有个问题是,去到 设置密码那里。点取消还是继续往下设置完成!
发表于 2009-6-1 21:24:27 | 显示全部楼层
6# wmiisht


用户点击“取消”需要通过判断@error来作相应处理。根据InputBox函数说明,点击“取消”后返回的@error值为2,请再加入相关语句。

例:
$PASSWORD = InputBox("自动登陆", "请输入密码:", $PASS, "*", 250, 100)
If @error = 2 Then ...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-25 21:22 , Processed in 0.073340 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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