jackass110 发表于 2009-10-3 12:35:32

倒计时循环执行,间隔时间执行

本帖最后由 jackass110 于 2009-10-8 03:58 编辑

代码如下,想实现启动时执行网络验证ID,验证成功的话就执行 “主执行程序代码”,并且每隔4小时重新验证ID,如果验证失败就每5秒执行一次验证动作,直到验证成功

请教如何实现 每隔4小时重新验证ID验证失败就每5秒执行一次验证动作,直到验证成功
发完贴子,想到了一些思路,改chickid()执行结果为返回值,菜鸟,请大家指正下错误并提供些方法
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <SHAppBarMessage.au3>
#NoTrayIcon

FileDelete(@TempDir & "\Idcheck.ini")

$Form1 = GUICreate("Form1", 320, 220, -1, -1, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW, WinGetHandle(AutoItWinGetTitle()))
$Pic1 = GUICtrlCreatePic("F:\新建文件夹\20090404_dfcd1ae67db3390faa5dyaeq3zXPqpN0.jpg", 0, 0, 320, 220, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("检查程序更新……", 8, 192, 300, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x800000)
GUISetState(@SW_SHOW)
$check = chickid()
If $check = "true" Then
        Runeyoo()
ElseIf $check = "noid" Then
        MsgBox(0, "", "未注册")
ElseIf $check = "false" Then
        $time = 5
        AdlibEnable("time", 1000)
EndIf
While 1
$msg = GUIGetMsg(1)

Select
    Case $msg = $Pic1
       
EndSelect
WEnd





Func Time();倒计时执行语句
        If $time = 0 Then
                chickid()
        EndIf
        GUICtrlSetData($Label1, "连接失败" & $time & "秒后重试..")
        $time -= 1
EndFunc   ;==>Time

Func chickid()
        $userid = IniRead(@ScriptDir & "\Config\menuchk.ini", "menuchk", "serviceid", "11")
        $GetIdcheck = InetGet("http://127.0.0.1/api.asp?id=" & $userid, @TempDir & "\Idcheck.ini", 1, 0)
        If $GetIdcheck = "1" Then
                $loadidcheck = FileReadLine(@TempDir & "\Idcheck.ini", 1)
                If $loadidcheck = "NoThisID" Then
                        Return("noid")
                        Exit
                Else
Return("true")
                EndIf
        EndIf
        If @error Then
                Return("false")
        EndIf
EndFunc   ;==>chickid

Func runeyoo()
        ShellExecute(@ScriptDir & "\manager.exe")
        ;GUICtrlSetState($Form1, @SW_HIDE)
        ;Sleep(600000)
        ;RegDelete
        Exit
EndFunc   

afan 发表于 2009-10-3 22:31:54

缺少 SHAppBarMessage.au3 ,没法调试...

afan 发表于 2009-10-3 23:46:39

本帖最后由 afan 于 2009-10-4 01:30 编辑

找了个 SHAppBarMessage.au3。。。是不是这个意思:
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <SHAppBarMessage.au3>
#NoTrayIcon

FileDelete(@TempDir & "\Idcheck.ini")
$Form1 = GUICreate("Form1", 320, 220, -1, -1, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW, WinGetHandle(AutoItWinGetTitle()))
$Pic1 = GUICtrlCreatePic("F:\新建文件夹\20090404_dfcd1ae67db3390faa5dyaeq3zXPqpN0.jpg", 0, 0, 320, 220, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("检查程序更新……", 8, 192, 300, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x800000)
GUISetState()
$begin = TimerInit()
Dim $check, $time = 5
Nchickid()

While 1
        $dif = TimerDiff($begin)
        If $dif > 14400000 Then
                $begin = TimerInit()
                Nchickid()
        EndIf
        $msg = GUIGetMsg(1)
        Select
                Case $msg = $Pic1
        EndSelect
WEnd

Func Nchickid()
        $check = chickid()
        If $check = "true" Then
                Runeyoo()
        ElseIf $check = "noid" Then
                MsgBox(0, "", "未注册")
        ElseIf $check = "false" Then
                AdlibEnable("time", 1000)
        EndIf
EndFunc   ;==>Nchickid

Func Time();倒计时执行语句
        If $time < 0 Then
                $time = 5
                GUICtrlSetData($Label1, "检查程序更新……")
                If chickid() = "true" Then
                        GUICtrlSetData($Label1, "验证通过,启动程序 ")
                        Runeyoo()
                        AdlibDisable()
                EndIf
        EndIf
        GUICtrlSetData($Label1, "连接失败" & $time & "秒后重试..")
        $time -= 1
EndFunc   ;==>Time

Func chickid()
        $userid = IniRead(@ScriptDir & "\Config\menuchk.ini", "menuchk", "serviceid", "11")
        $GetIdcheck = InetGet("http://127.0.0.1/api.asp?id=" & $userid, @TempDir & "\Idcheck.ini", 1, 0)
        If $GetIdcheck = "1" Then
                $loadidcheck = FileReadLine(@TempDir & "\Idcheck.ini", 1)
                If $loadidcheck = "NoThisID" Then
                        Return ("noid")
                        Exit
                Else
                        Return ("true")
                EndIf
        EndIf
        If @error Then
                Return ("false")
        EndIf
EndFunc   ;==>chickid

Func runeyoo()
        ShellExecute(@ScriptDir & "\manager.exe")
        ;GUICtrlSetState($Form1, @SW_HIDE)
        ;Sleep(600000)
        ;RegDelete
        ;Exit
EndFunc   ;==>runeyoo

jackass110 发表于 2009-10-8 03:58:00

谢谢“afan ”的热心指教,就是这个样的,


感激涕零

jianganew 发表于 2014-11-16 14:40:48

学习了,谢谢!
页: [1]
查看完整版本: 倒计时循环执行,间隔时间执行