找回密码
 加入
搜索
查看: 3479|回复: 7

发个启动程序动态密码验证原码,再提个问题.

  [复制链接]
发表于 2010-1-9 12:06:43 | 显示全部楼层 |阅读模式
本帖最后由 cls822001 于 2010-1-9 12:52 编辑

出掉红色部分就是一次错误退出启动...................

问题是验证错误次数部分,怎么写才能3次错误后退出,搞很多次都是有问题.循环主太会,找大大们学习一下


#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$pa = "password"
$set1 = @YEAR
$set2 = @HOUR & @MIN

$Form1 = GUICreate("请输入动态密码", 231, 120, -1, -1, 0x16C80080)
GUISetFont(10, 400, 0, "微软雅黑")
$Label1 = GUICtrlCreateLabel("程序启动密码专用", 49, 12, 132, 20)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
$Button1 = GUICtrlCreateButton("确定", 24, 80, 81, 33)
$Address = GUICtrlCreateInput("", 45, 40, 134, 26, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_PASSWORD))
$Button2 = GUICtrlCreateButton("取消", 128, 80, 81, 33)
Dim $AccelKeys[1][2] = [["{Enter}", $Button1]]
GUISetAccelerators($AccelKeys)
GUICtrlSetState($Address, $GUI_FOCUS)
GUISetState(@SW_SHOW)


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ProcessClose("a.EXE")
                        FileDelete(@ScriptDir & "\a.exe")
                        Exit
                Case $Button1
                        $pass = GUICtrlRead(5)
                        $password = $set1 & $pa & $set2
                                               
                If $password <> $pass Then
                                                  for $i=1 to 3
                                                         $i=3 then exit GUICtrlSetData($Label1, "错误次数超出范围")
                                                $pass = GUICtrlSetData($Label1, "错误次数"& 3-$i & "次")

                                       

                                                     
                        If $password = $pass Then
                                GUICtrlSetData($Label1, "动态密码输入正确")
                                GUICtrlSetData($Label1, "程序启动中请稍候")
                                FileInstall("C:\Users\china\Desktop\a\a.exe", @ScriptDir & "\a.exe", 1)
                                GUISetState(@SW_HIDE)
                                Run(@ScriptDir & "\a.exe")
                                ProcessWaitClose("a.exe")
                                FileDelete(@ScriptDir & "\a.exe")
                                Exit
                        Else
                                GUICtrlSetData($Label1, "密码错误程序退出")
                                Sleep(1000)
                                Exit
                        EndIf
                Case $Button2
                        ProcessClose("a.EXE")
                        FileDelete(@ScriptDir & "\a.exe")
                        Exit

        EndSwitch
WEnd
发表于 2010-1-9 12:38:37 | 显示全部楼层
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$pa = "password"
$set1 = @YEAR
$set2 = @HOUR & @MIN

$Form1 = GUICreate("请输入动态密码", 231, 120, -1, -1, 0x16C80080)
GUISetFont(10, 400, 0, "微软雅黑")
$Label1 = GUICtrlCreateLabel("程序启动密码专用", 49, 12, 132, 20)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
$Button1 = GUICtrlCreateButton("确定", 24, 80, 81, 33)
$Address = GUICtrlCreateInput("", 45, 40, 134, 26, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_PASSWORD))
$Button2 = GUICtrlCreateButton("取消", 128, 80, 81, 33)
Dim $AccelKeys[1][2] = [["{Enter}", $Button1]]
GUISetAccelerators($AccelKeys)
GUICtrlSetState($Address, $GUI_FOCUS)
GUISetState(@SW_SHOW)
$i = 1

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ProcessClose("a.EXE")
                        FileDelete(@ScriptDir & "\a.exe")
                        Exit
                Case $Button1
                        pass()
                Case $Button2
                        ProcessClose("a.EXE")
                        FileDelete(@ScriptDir & "\a.exe")
                        Exit

        EndSwitch
WEnd

Func pass()
        $password = $set1 & $pa & $set2
        $pass = GUICtrlRead(5)
        If $password <> $pass Then
                If $i = 3 Then
                        GUICtrlSetData($Label1, "错误次数超出范围")
                        Sleep(1000)
                        Exit
                Else
                        GUICtrlSetData($Label1, "错误次数" & $i & "次")
                EndIf
        $i += 1
        Else
                GUICtrlSetData($Label1, "动态密码输入正确")
                Sleep(300)
                GUICtrlSetData($Label1, "程序启动中请稍候")
                Sleep(300)
                FileInstall("C:\Users\china\Desktop\a\a.exe", @ScriptDir & "\a.exe", 1)
                GUISetState(@SW_HIDE)
                Run(@ScriptDir & "\a.exe")
                ProcessWaitClose("a.exe")
                FileDelete(@ScriptDir & "\a.exe")
                Exit
        EndIf
EndFunc   ;==>pass

评分

参与人数 1金钱 +10 收起 理由
顽固不化 + 10

查看全部评分

 楼主| 发表于 2010-1-9 12:51:08 | 显示全部楼层
谢谢老大...
发表于 2011-1-17 11:29:47 | 显示全部楼层
那么原始应该在哪位置
发表于 2012-3-13 19:31:52 | 显示全部楼层
密码应该在哪儿呢?
发表于 2012-3-24 17:24:47 | 显示全部楼层
很梦。很强大
发表于 2012-3-27 14:26:35 | 显示全部楼层
那么原始应该在哪位置
发表于 2014-5-20 09:11:35 | 显示全部楼层
密碼去哪兒啦
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 05:17 , Processed in 0.093748 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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