Jump to content

[Solved] How to stop a time counter when a specific time reached


Recommended Posts

Hi sir,

I have added a time counter into my code as below, when the GUI tool be launched then the counter will start to count the time, and I want to let it stop counting when the specific time is reached, for example, when time counter count to 60 hours then it stop the count automatically, please advise how to do that, thanks.

Global $sTimer, $Dll_Timer, $hour, $min, $sec

$begin = TimerInit()
AdlibRegister("SetTime", 1000)

Func SetTime()
    Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%02i:%02i:%02i", $hour, $min, $sec))
EndFunc

Jacky

Edited by jackylee0908
Link to comment
Share on other sites

You could disable the the AdLib function by using AdLibUnRegister which will clear the function call.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

On 8/28/2019 at 7:46 PM, BrewManNH said:

You could disable the the AdLib function by using AdLibUnRegister which will clear the function call.

Hi @BrewManNH,

Yap I know it, but I don't know how to judge if it reaches the specific time, could you help?

I have tried below code but nothing happen for me.

Global $sTimer, $Dll_Timer, $hour, $min, $sec

$begin = TimerInit()
AdlibRegister("SetTime", 1000)

If (GUICtrlRead($hour) = 0 And GUICtrlRead($min) = 0 And GUICtrlRead($sec) = 10) Then
    MsgBox(64, "", "Time's out", 3)
EndIf

Func SetTime()
    Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
EndFunc

- or

Global $sTimer, $Dll_Timer, $hour, $min, $sec

$begin = TimerInit()
AdlibRegister("SetTime", 1000)

Func SetTime()
    Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
    If (GUICtrlRead($hour) = 0 And GUICtrlRead($min) = 0 And GUICtrlRead($sec) = 10) Then
        MsgBox(64, "", "Time's out", 3)
    EndIf
EndFunc

Thanks.

Edited by jackylee0908
Link to comment
Share on other sites

This works for me. AdlibRegister() is effective only while the program lasts.

$begin = TimerInit()
AdlibRegister("SetTime", 5000)

While 1
    If TimerDiff($begin) > 30000 Then
;       AdlibUnRegister("SetTime")
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Func SetTime()
;   Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
;   ControlSetText($Dashboard, "", $Label12, StringFormat("%02i:%02i:%02i", $hour, $min, $sec))
    MsgBox(0, '', Round(TimerDiff($begin)/1000), 1)
EndFunc

 

Edited by CYCho
Link to comment
Share on other sites

Sorry, let me post the detailed code here.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Process.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>

#Region ### START Koda GUI section ### Form=c:\jacky\wugu\test tools\autoit3 codes\dashboard4.kxf
Global $Dashboard = GUICreate("Stress Test Dashboard v1.1 2019/08/22 (Developed by Flex TDC-SIT Jacky Lee)", 955, 708, 393, 78)
Global $Label1 = GUICtrlCreateLabel("Dashboard", 32, 8, 149, 36)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Group1 = GUICtrlCreateGroup("Counter", 32, 56, 433, 481)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("CONT0 BMC FRU Check", 56, 112, 153, 20)
Global $Label3 = GUICtrlCreateLabel("CONT1 BMC FRU Check", 56, 144, 153, 20)
Global $Label4 = GUICtrlCreateLabel("CONT0 BMC Sensor Check", 56, 176, 168, 20)
Global $Label5 = GUICtrlCreateLabel("CONT1 BMC Sensor Check", 56, 208, 168, 20)
Global $Label14 = GUICtrlCreateLabel("CONT0 BMC MC Info Check", 56, 240, 137, 20)
Global $Label15 = GUICtrlCreateLabel("CONT1 BMC MC Info Check", 56, 272, 137, 20)
Global $Label18 = GUICtrlCreateLabel("CONT0 BMC Self-Test Check", 56, 304, 179, 20)
Global $Label20 = GUICtrlCreateLabel("CONT1 BMC Self-Test Check", 56, 336, 179, 20)
Global $Label6 = GUICtrlCreateLabel("CONT0/1 LAN Port Ping Test", 56, 368, 187, 20)
Global $Label7 = GUICtrlCreateLabel("CONT0 BMC SEL NG Count", 56, 400, 187, 20)
Global $Label8 = GUICtrlCreateLabel("CONT1 BMC SEL NG Count", 56, 432, 176, 20)
Global $Label19 = GUICtrlCreateLabel("CONT0 Check Timeout Count", 56, 464, 179, 20)
Global $Label13 = GUICtrlCreateLabel("CONT1 Check Timeout Count", 56, 496, 179, 20)
Global $Label16 = GUICtrlCreateLabel("PASS", 240, 80, 44, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Label17 = GUICtrlCreateLabel("FAIL", 312, 80, 35, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $Label23 = GUICtrlCreateLabel("F/R (%)", 376, 80, 56, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x0078D7)
Global $List1 = GUICtrlCreateList("", 240, 112, 41, 22, $LBS_NOSEL)
Global $List2 = GUICtrlCreateList("", 240, 144, 41, 22, $LBS_NOSEL)
Global $List3 = GUICtrlCreateList("", 240, 176, 41, 22, $LBS_NOSEL)
Global $List4 = GUICtrlCreateList("", 240, 208, 41, 22, $LBS_NOSEL)
Global $List5 = GUICtrlCreateList("", 240, 240, 41, 22, $LBS_NOSEL)
Global $List6 = GUICtrlCreateList("", 240, 272, 41, 22, $LBS_NOSEL)
Global $List11 = GUICtrlCreateList("", 240, 304, 41, 22, $LBS_NOSEL)
Global $List12 = GUICtrlCreateList("", 240, 336, 41, 22, $LBS_NOSEL)
Global $List27 = GUICtrlCreateList("", 240, 368, 41, 22, $LBS_NOSEL)
Global $List28 = GUICtrlCreateList("", 240, 400, 41, 22, $LBS_NOSEL)
Global $List7 = GUICtrlCreateList("", 240, 432, 41, 22, $LBS_NOSEL)
Global $List13 = GUICtrlCreateList("", 240, 464, 41, 22, $LBS_NOSEL)
Global $List14 = GUICtrlCreateList("", 240, 496, 41, 22, $LBS_NOSEL)
Global $List = GUICtrlCreateList("", 312, 112, 41, 22, $LBS_NOSEL)
Global $List16 = GUICtrlCreateList("", 312, 144, 41, 22, $LBS_NOSEL)
Global $List17 = GUICtrlCreateList("", 312, 176, 41, 22, $LBS_NOSEL)
Global $List18 = GUICtrlCreateList("", 312, 208, 41, 22, $LBS_NOSEL)
Global $List19 = GUICtrlCreateList("", 312, 240, 41, 22, $LBS_NOSEL)
Global $List20 = GUICtrlCreateList("", 312, 272, 41, 22, $LBS_NOSEL)
Global $List23 = GUICtrlCreateList("", 312, 304, 41, 22, $LBS_NOSEL)
Global $List24 = GUICtrlCreateList("", 312, 336, 41, 22, $LBS_NOSEL)
Global $List29 = GUICtrlCreateList("", 312, 368, 41, 22, $LBS_NOSEL)
Global $List30 = GUICtrlCreateList("", 312, 400, 41, 22, $LBS_NOSEL)
Global $List21 = GUICtrlCreateList("", 312, 432, 41, 22, $LBS_NOSEL)
Global $List15 = GUICtrlCreateList("", 312, 464, 41, 22, $LBS_NOSEL)
Global $List22 = GUICtrlCreateList("", 312, 496, 41, 22, $LBS_NOSEL)
Global $List34 = GUICtrlCreateList("", 376, 112, 41, 22, $LBS_NOSEL)
Global $List35 = GUICtrlCreateList("", 376, 144, 41, 22, $LBS_NOSEL)
Global $List36 = GUICtrlCreateList("", 376, 176, 41, 22, $LBS_NOSEL)
Global $List37 = GUICtrlCreateList("", 376, 208, 41, 22, $LBS_NOSEL)
Global $List38 = GUICtrlCreateList("", 376, 240, 41, 22, $LBS_NOSEL)
Global $List39 = GUICtrlCreateList("", 376, 272, 41, 22, $LBS_NOSEL)
Global $List25 = GUICtrlCreateList("", 376, 304, 41, 22, $LBS_NOSEL)
Global $List26 = GUICtrlCreateList("", 376, 336, 41, 22, $LBS_NOSEL)
Global $List31 = GUICtrlCreateList("", 376, 368, 41, 22, $LBS_NOSEL)
Global $List32 = GUICtrlCreateList("", 376, 400, 41, 22, $LBS_NOSEL)
Global $List40 = GUICtrlCreateList("", 376, 432, 41, 22, $LBS_NOSEL)
Global $List9 = GUICtrlCreateList("", 376, 464, 41, 22, $LBS_NOSEL)
Global $List10 = GUICtrlCreateList("", 376, 496, 41, 22, $LBS_NOSEL)
Global $Group2 = GUICtrlCreateGroup("Status Box", 488, 56, 433, 281)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel("Current Cycle #", 600, 88, 197, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List33 = GUICtrlCreateList("", 632, 136, 129, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 36, 400, 0, "MS Sans Serif")
Global $Label9 = GUICtrlCreateLabel("Test Time Counter", 584, 224, 241, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Label12 = GUICtrlCreateLabel("000:00:00", 614, 272, 188, 50)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $btnExit = GUICtrlCreateButton("Exit", 824, 16, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnFL = GUICtrlCreateButton("Failure Logs", 680, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnScr = GUICtrlCreateButton("Take ScreenShot", 496, 16, 139, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnZip = GUICtrlCreateButton("Zip testlog", 352, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $Group3 = GUICtrlCreateGroup("Message Box", 32, 544, 889, 145)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $msgbox = GUICtrlCreateEdit("", 56, 584, 601, 81, $ES_READONLY)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Label11 = GUICtrlCreateLabel("Count Down Timer", 706, 564, 183, 29, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List8 = GUICtrlCreateList("", 752, 600, 89, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $Group4 = GUICtrlCreateGroup("BMC SEL Counter - CONT0 / CONT1", 488, 352, 433, 185)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $bmcselcounter1 = GUICtrlCreateEdit("", 512, 384, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
Global $bmcselcounter2 = GUICtrlCreateEdit("", 512, 457, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $sTimer, $Dll_Timer, $hour, $min, $sec

$begin = TimerInit()
AdlibRegister("SetTime", 5000)

While 1
    If TimerDiff($begin) > 30000 Then
;       AdlibUnRegister("SetTime")
        ExitLoop
    EndIf
    Sleep(100)
WEnd

If (GUICtrlRead($hour) = 0 And GUICtrlRead($min) = 0 And GUICtrlRead($sec) = 10) Then
    MsgBox(64, "", "Time's out", 3)
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func SetTime()
    Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
;   If (GUICtrlRead($hour) = 0 And GUICtrlRead($min) = 0 And GUICtrlRead($sec) = 10) Then
;       MsgBox(64, "", "Time's out", 3)
;   EndIf
EndFunc

It is a part of my test script, I'd want to let user input how many hours he desire the script to perform a cycle test(other code), and when the time counter reaches the time which user set, then the time counter will stop counting and test will be complete when last cycle test is finished.

I think I need a code to check if the set up time is reached or not on the end of every cycle test, and I need the code to check if the time is reached or not.

Thanks.

Link to comment
Share on other sites

Try this.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Process.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>

#Region ### START Koda GUI section ### Form=c:\jacky\wugu\test tools\autoit3 codes\dashboard4.kxf
Global $Dashboard = GUICreate("Stress Test Dashboard v1.1 2019/08/22 (Developed by Flex TDC-SIT Jacky Lee)", 955, 708, 393, 78)
Global $Label1 = GUICtrlCreateLabel("Dashboard", 32, 8, 149, 36)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Group1 = GUICtrlCreateGroup("Counter", 32, 56, 433, 481)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("CONT0 BMC FRU Check", 56, 112, 153, 20)
Global $Label3 = GUICtrlCreateLabel("CONT1 BMC FRU Check", 56, 144, 153, 20)
Global $Label4 = GUICtrlCreateLabel("CONT0 BMC Sensor Check", 56, 176, 168, 20)
Global $Label5 = GUICtrlCreateLabel("CONT1 BMC Sensor Check", 56, 208, 168, 20)
Global $Label14 = GUICtrlCreateLabel("CONT0 BMC MC Info Check", 56, 240, 137, 20)
Global $Label15 = GUICtrlCreateLabel("CONT1 BMC MC Info Check", 56, 272, 137, 20)
Global $Label18 = GUICtrlCreateLabel("CONT0 BMC Self-Test Check", 56, 304, 179, 20)
Global $Label20 = GUICtrlCreateLabel("CONT1 BMC Self-Test Check", 56, 336, 179, 20)
Global $Label6 = GUICtrlCreateLabel("CONT0/1 LAN Port Ping Test", 56, 368, 187, 20)
Global $Label7 = GUICtrlCreateLabel("CONT0 BMC SEL NG Count", 56, 400, 187, 20)
Global $Label8 = GUICtrlCreateLabel("CONT1 BMC SEL NG Count", 56, 432, 176, 20)
Global $Label19 = GUICtrlCreateLabel("CONT0 Check Timeout Count", 56, 464, 179, 20)
Global $Label13 = GUICtrlCreateLabel("CONT1 Check Timeout Count", 56, 496, 179, 20)
Global $Label16 = GUICtrlCreateLabel("PASS", 240, 80, 44, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Label17 = GUICtrlCreateLabel("FAIL", 312, 80, 35, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $Label23 = GUICtrlCreateLabel("F/R (%)", 376, 80, 56, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x0078D7)
Global $List1 = GUICtrlCreateList("", 240, 112, 41, 22, $LBS_NOSEL)
Global $List2 = GUICtrlCreateList("", 240, 144, 41, 22, $LBS_NOSEL)
Global $List3 = GUICtrlCreateList("", 240, 176, 41, 22, $LBS_NOSEL)
Global $List4 = GUICtrlCreateList("", 240, 208, 41, 22, $LBS_NOSEL)
Global $List5 = GUICtrlCreateList("", 240, 240, 41, 22, $LBS_NOSEL)
Global $List6 = GUICtrlCreateList("", 240, 272, 41, 22, $LBS_NOSEL)
Global $List11 = GUICtrlCreateList("", 240, 304, 41, 22, $LBS_NOSEL)
Global $List12 = GUICtrlCreateList("", 240, 336, 41, 22, $LBS_NOSEL)
Global $List27 = GUICtrlCreateList("", 240, 368, 41, 22, $LBS_NOSEL)
Global $List28 = GUICtrlCreateList("", 240, 400, 41, 22, $LBS_NOSEL)
Global $List7 = GUICtrlCreateList("", 240, 432, 41, 22, $LBS_NOSEL)
Global $List13 = GUICtrlCreateList("", 240, 464, 41, 22, $LBS_NOSEL)
Global $List14 = GUICtrlCreateList("", 240, 496, 41, 22, $LBS_NOSEL)
Global $List = GUICtrlCreateList("", 312, 112, 41, 22, $LBS_NOSEL)
Global $List16 = GUICtrlCreateList("", 312, 144, 41, 22, $LBS_NOSEL)
Global $List17 = GUICtrlCreateList("", 312, 176, 41, 22, $LBS_NOSEL)
Global $List18 = GUICtrlCreateList("", 312, 208, 41, 22, $LBS_NOSEL)
Global $List19 = GUICtrlCreateList("", 312, 240, 41, 22, $LBS_NOSEL)
Global $List20 = GUICtrlCreateList("", 312, 272, 41, 22, $LBS_NOSEL)
Global $List23 = GUICtrlCreateList("", 312, 304, 41, 22, $LBS_NOSEL)
Global $List24 = GUICtrlCreateList("", 312, 336, 41, 22, $LBS_NOSEL)
Global $List29 = GUICtrlCreateList("", 312, 368, 41, 22, $LBS_NOSEL)
Global $List30 = GUICtrlCreateList("", 312, 400, 41, 22, $LBS_NOSEL)
Global $List21 = GUICtrlCreateList("", 312, 432, 41, 22, $LBS_NOSEL)
Global $List15 = GUICtrlCreateList("", 312, 464, 41, 22, $LBS_NOSEL)
Global $List22 = GUICtrlCreateList("", 312, 496, 41, 22, $LBS_NOSEL)
Global $List34 = GUICtrlCreateList("", 376, 112, 41, 22, $LBS_NOSEL)
Global $List35 = GUICtrlCreateList("", 376, 144, 41, 22, $LBS_NOSEL)
Global $List36 = GUICtrlCreateList("", 376, 176, 41, 22, $LBS_NOSEL)
Global $List37 = GUICtrlCreateList("", 376, 208, 41, 22, $LBS_NOSEL)
Global $List38 = GUICtrlCreateList("", 376, 240, 41, 22, $LBS_NOSEL)
Global $List39 = GUICtrlCreateList("", 376, 272, 41, 22, $LBS_NOSEL)
Global $List25 = GUICtrlCreateList("", 376, 304, 41, 22, $LBS_NOSEL)
Global $List26 = GUICtrlCreateList("", 376, 336, 41, 22, $LBS_NOSEL)
Global $List31 = GUICtrlCreateList("", 376, 368, 41, 22, $LBS_NOSEL)
Global $List32 = GUICtrlCreateList("", 376, 400, 41, 22, $LBS_NOSEL)
Global $List40 = GUICtrlCreateList("", 376, 432, 41, 22, $LBS_NOSEL)
Global $List9 = GUICtrlCreateList("", 376, 464, 41, 22, $LBS_NOSEL)
Global $List10 = GUICtrlCreateList("", 376, 496, 41, 22, $LBS_NOSEL)
Global $Group2 = GUICtrlCreateGroup("Status Box", 488, 56, 433, 281)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel("Current Cycle #", 600, 88, 197, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List33 = GUICtrlCreateList("", 632, 136, 129, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 36, 400, 0, "MS Sans Serif")
Global $Label9 = GUICtrlCreateLabel("Test Time Counter", 584, 224, 241, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Label12 = GUICtrlCreateLabel("000:00:00", 614, 272, 188, 50)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $btnExit = GUICtrlCreateButton("Exit", 824, 16, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnFL = GUICtrlCreateButton("Failure Logs", 680, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnScr = GUICtrlCreateButton("Take ScreenShot", 496, 16, 139, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnZip = GUICtrlCreateButton("Zip testlog", 352, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $Group3 = GUICtrlCreateGroup("Message Box", 32, 544, 889, 145)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $msgbox = GUICtrlCreateEdit("", 56, 584, 601, 81, $ES_READONLY)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Label11 = GUICtrlCreateLabel("Count Down Timer", 706, 564, 183, 29, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List8 = GUICtrlCreateList("", 752, 600, 89, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $Group4 = GUICtrlCreateGroup("BMC SEL Counter - CONT0 / CONT1", 488, 352, 433, 185)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $bmcselcounter1 = GUICtrlCreateEdit("", 512, 384, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
Global $bmcselcounter2 = GUICtrlCreateEdit("", 512, 457, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $sTimer, $Dll_Timer, $hour, $min, $sec

$begin = TimerInit()
AdlibRegister("SetTime", 1000)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    If GUICtrlRead($Label12) = "000:00:10" Then
        AdlibUnRegister("SetTime")
        GUICtrlSetData($Label12, "000:00:00")
        MsgBox(64, "", "Time's out", 3)
    EndIf
WEnd

Func SetTime()
    Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
EndFunc

It seems that you need a user input box (GUICtrlCreateInput) for the duration of test and a button to initialize the timer and restart the adlibregister. 

Edited by CYCho
Link to comment
Share on other sites

On 8/30/2019 at 6:34 PM, CYCho said:

Try this.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Process.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>

#Region ### START Koda GUI section ### Form=c:\jacky\wugu\test tools\autoit3 codes\dashboard4.kxf
Global $Dashboard = GUICreate("Stress Test Dashboard v1.1 2019/08/22 (Developed by Flex TDC-SIT Jacky Lee)", 955, 708, 393, 78)
Global $Label1 = GUICtrlCreateLabel("Dashboard", 32, 8, 149, 36)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Group1 = GUICtrlCreateGroup("Counter", 32, 56, 433, 481)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("CONT0 BMC FRU Check", 56, 112, 153, 20)
Global $Label3 = GUICtrlCreateLabel("CONT1 BMC FRU Check", 56, 144, 153, 20)
Global $Label4 = GUICtrlCreateLabel("CONT0 BMC Sensor Check", 56, 176, 168, 20)
Global $Label5 = GUICtrlCreateLabel("CONT1 BMC Sensor Check", 56, 208, 168, 20)
Global $Label14 = GUICtrlCreateLabel("CONT0 BMC MC Info Check", 56, 240, 137, 20)
Global $Label15 = GUICtrlCreateLabel("CONT1 BMC MC Info Check", 56, 272, 137, 20)
Global $Label18 = GUICtrlCreateLabel("CONT0 BMC Self-Test Check", 56, 304, 179, 20)
Global $Label20 = GUICtrlCreateLabel("CONT1 BMC Self-Test Check", 56, 336, 179, 20)
Global $Label6 = GUICtrlCreateLabel("CONT0/1 LAN Port Ping Test", 56, 368, 187, 20)
Global $Label7 = GUICtrlCreateLabel("CONT0 BMC SEL NG Count", 56, 400, 187, 20)
Global $Label8 = GUICtrlCreateLabel("CONT1 BMC SEL NG Count", 56, 432, 176, 20)
Global $Label19 = GUICtrlCreateLabel("CONT0 Check Timeout Count", 56, 464, 179, 20)
Global $Label13 = GUICtrlCreateLabel("CONT1 Check Timeout Count", 56, 496, 179, 20)
Global $Label16 = GUICtrlCreateLabel("PASS", 240, 80, 44, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Label17 = GUICtrlCreateLabel("FAIL", 312, 80, 35, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $Label23 = GUICtrlCreateLabel("F/R (%)", 376, 80, 56, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x0078D7)
Global $List1 = GUICtrlCreateList("", 240, 112, 41, 22, $LBS_NOSEL)
Global $List2 = GUICtrlCreateList("", 240, 144, 41, 22, $LBS_NOSEL)
Global $List3 = GUICtrlCreateList("", 240, 176, 41, 22, $LBS_NOSEL)
Global $List4 = GUICtrlCreateList("", 240, 208, 41, 22, $LBS_NOSEL)
Global $List5 = GUICtrlCreateList("", 240, 240, 41, 22, $LBS_NOSEL)
Global $List6 = GUICtrlCreateList("", 240, 272, 41, 22, $LBS_NOSEL)
Global $List11 = GUICtrlCreateList("", 240, 304, 41, 22, $LBS_NOSEL)
Global $List12 = GUICtrlCreateList("", 240, 336, 41, 22, $LBS_NOSEL)
Global $List27 = GUICtrlCreateList("", 240, 368, 41, 22, $LBS_NOSEL)
Global $List28 = GUICtrlCreateList("", 240, 400, 41, 22, $LBS_NOSEL)
Global $List7 = GUICtrlCreateList("", 240, 432, 41, 22, $LBS_NOSEL)
Global $List13 = GUICtrlCreateList("", 240, 464, 41, 22, $LBS_NOSEL)
Global $List14 = GUICtrlCreateList("", 240, 496, 41, 22, $LBS_NOSEL)
Global $List = GUICtrlCreateList("", 312, 112, 41, 22, $LBS_NOSEL)
Global $List16 = GUICtrlCreateList("", 312, 144, 41, 22, $LBS_NOSEL)
Global $List17 = GUICtrlCreateList("", 312, 176, 41, 22, $LBS_NOSEL)
Global $List18 = GUICtrlCreateList("", 312, 208, 41, 22, $LBS_NOSEL)
Global $List19 = GUICtrlCreateList("", 312, 240, 41, 22, $LBS_NOSEL)
Global $List20 = GUICtrlCreateList("", 312, 272, 41, 22, $LBS_NOSEL)
Global $List23 = GUICtrlCreateList("", 312, 304, 41, 22, $LBS_NOSEL)
Global $List24 = GUICtrlCreateList("", 312, 336, 41, 22, $LBS_NOSEL)
Global $List29 = GUICtrlCreateList("", 312, 368, 41, 22, $LBS_NOSEL)
Global $List30 = GUICtrlCreateList("", 312, 400, 41, 22, $LBS_NOSEL)
Global $List21 = GUICtrlCreateList("", 312, 432, 41, 22, $LBS_NOSEL)
Global $List15 = GUICtrlCreateList("", 312, 464, 41, 22, $LBS_NOSEL)
Global $List22 = GUICtrlCreateList("", 312, 496, 41, 22, $LBS_NOSEL)
Global $List34 = GUICtrlCreateList("", 376, 112, 41, 22, $LBS_NOSEL)
Global $List35 = GUICtrlCreateList("", 376, 144, 41, 22, $LBS_NOSEL)
Global $List36 = GUICtrlCreateList("", 376, 176, 41, 22, $LBS_NOSEL)
Global $List37 = GUICtrlCreateList("", 376, 208, 41, 22, $LBS_NOSEL)
Global $List38 = GUICtrlCreateList("", 376, 240, 41, 22, $LBS_NOSEL)
Global $List39 = GUICtrlCreateList("", 376, 272, 41, 22, $LBS_NOSEL)
Global $List25 = GUICtrlCreateList("", 376, 304, 41, 22, $LBS_NOSEL)
Global $List26 = GUICtrlCreateList("", 376, 336, 41, 22, $LBS_NOSEL)
Global $List31 = GUICtrlCreateList("", 376, 368, 41, 22, $LBS_NOSEL)
Global $List32 = GUICtrlCreateList("", 376, 400, 41, 22, $LBS_NOSEL)
Global $List40 = GUICtrlCreateList("", 376, 432, 41, 22, $LBS_NOSEL)
Global $List9 = GUICtrlCreateList("", 376, 464, 41, 22, $LBS_NOSEL)
Global $List10 = GUICtrlCreateList("", 376, 496, 41, 22, $LBS_NOSEL)
Global $Group2 = GUICtrlCreateGroup("Status Box", 488, 56, 433, 281)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel("Current Cycle #", 600, 88, 197, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List33 = GUICtrlCreateList("", 632, 136, 129, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 36, 400, 0, "MS Sans Serif")
Global $Label9 = GUICtrlCreateLabel("Test Time Counter", 584, 224, 241, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Label12 = GUICtrlCreateLabel("000:00:00", 614, 272, 188, 50)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $btnExit = GUICtrlCreateButton("Exit", 824, 16, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnFL = GUICtrlCreateButton("Failure Logs", 680, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnScr = GUICtrlCreateButton("Take ScreenShot", 496, 16, 139, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnZip = GUICtrlCreateButton("Zip testlog", 352, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $Group3 = GUICtrlCreateGroup("Message Box", 32, 544, 889, 145)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $msgbox = GUICtrlCreateEdit("", 56, 584, 601, 81, $ES_READONLY)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Label11 = GUICtrlCreateLabel("Count Down Timer", 706, 564, 183, 29, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List8 = GUICtrlCreateList("", 752, 600, 89, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $Group4 = GUICtrlCreateGroup("BMC SEL Counter - CONT0 / CONT1", 488, 352, 433, 185)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $bmcselcounter1 = GUICtrlCreateEdit("", 512, 384, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
Global $bmcselcounter2 = GUICtrlCreateEdit("", 512, 457, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $sTimer, $Dll_Timer, $hour, $min, $sec

$begin = TimerInit()
AdlibRegister("SetTime", 1000)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    If GUICtrlRead($Label12) = "000:00:10" Then
        AdlibUnRegister("SetTime")
        GUICtrlSetData($Label12, "000:00:00")
        MsgBox(64, "", "Time's out", 3)
    EndIf
WEnd

Func SetTime()
    Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
EndFunc

It seems that you need a user input box (GUICtrlCreateInput) for the duration of test and a button to initialize the timer and restart the adlibregister. 

Hi @CYCho,

Thanks, it worked for me, but I have one question, I need separate hours, minutes and seconds as variables, how can I do?

Say that, I have another GUI script and will provide input for user input value of hours, minutes and seconds, and then, the GUI script will deliver the value of hours, minutes and seconds to this script.

BTW, about below code:

If GUICtrlRead($Label12) = "000:00:10" Then
        AdlibUnRegister("SetTime")
        GUICtrlSetData($Label12, "000:00:00")
        MsgBox(64, "", "Time's out", 3)
    EndIf

Is it possible to no set the counter to "000:00:00" when specific time is reached, and only one time msgbox pup up?

Thanks.

Link to comment
Share on other sites

Assuming that you have a user input of "000:00:10" , the following code will work.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Process.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>

#Region ### START Koda GUI section ### Form=c:\jacky\wugu\test tools\autoit3 codes\dashboard4.kxf
Global $Dashboard = GUICreate("Stress Test Dashboard v1.1 2019/08/22 (Developed by Flex TDC-SIT Jacky Lee)", 955, 708, 393, 78)
Global $Label1 = GUICtrlCreateLabel("Dashboard", 32, 8, 149, 36)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Group1 = GUICtrlCreateGroup("Counter", 32, 56, 433, 481)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("CONT0 BMC FRU Check", 56, 112, 153, 20)
Global $Label3 = GUICtrlCreateLabel("CONT1 BMC FRU Check", 56, 144, 153, 20)
Global $Label4 = GUICtrlCreateLabel("CONT0 BMC Sensor Check", 56, 176, 168, 20)
Global $Label5 = GUICtrlCreateLabel("CONT1 BMC Sensor Check", 56, 208, 168, 20)
Global $Label14 = GUICtrlCreateLabel("CONT0 BMC MC Info Check", 56, 240, 137, 20)
Global $Label15 = GUICtrlCreateLabel("CONT1 BMC MC Info Check", 56, 272, 137, 20)
Global $Label18 = GUICtrlCreateLabel("CONT0 BMC Self-Test Check", 56, 304, 179, 20)
Global $Label20 = GUICtrlCreateLabel("CONT1 BMC Self-Test Check", 56, 336, 179, 20)
Global $Label6 = GUICtrlCreateLabel("CONT0/1 LAN Port Ping Test", 56, 368, 187, 20)
Global $Label7 = GUICtrlCreateLabel("CONT0 BMC SEL NG Count", 56, 400, 187, 20)
Global $Label8 = GUICtrlCreateLabel("CONT1 BMC SEL NG Count", 56, 432, 176, 20)
Global $Label19 = GUICtrlCreateLabel("CONT0 Check Timeout Count", 56, 464, 179, 20)
Global $Label13 = GUICtrlCreateLabel("CONT1 Check Timeout Count", 56, 496, 179, 20)
Global $Label16 = GUICtrlCreateLabel("PASS", 240, 80, 44, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Label17 = GUICtrlCreateLabel("FAIL", 312, 80, 35, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $Label23 = GUICtrlCreateLabel("F/R (%)", 376, 80, 56, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x0078D7)
Global $List1 = GUICtrlCreateList("", 240, 112, 41, 22, $LBS_NOSEL)
Global $List2 = GUICtrlCreateList("", 240, 144, 41, 22, $LBS_NOSEL)
Global $List3 = GUICtrlCreateList("", 240, 176, 41, 22, $LBS_NOSEL)
Global $List4 = GUICtrlCreateList("", 240, 208, 41, 22, $LBS_NOSEL)
Global $List5 = GUICtrlCreateList("", 240, 240, 41, 22, $LBS_NOSEL)
Global $List6 = GUICtrlCreateList("", 240, 272, 41, 22, $LBS_NOSEL)
Global $List11 = GUICtrlCreateList("", 240, 304, 41, 22, $LBS_NOSEL)
Global $List12 = GUICtrlCreateList("", 240, 336, 41, 22, $LBS_NOSEL)
Global $List27 = GUICtrlCreateList("", 240, 368, 41, 22, $LBS_NOSEL)
Global $List28 = GUICtrlCreateList("", 240, 400, 41, 22, $LBS_NOSEL)
Global $List7 = GUICtrlCreateList("", 240, 432, 41, 22, $LBS_NOSEL)
Global $List13 = GUICtrlCreateList("", 240, 464, 41, 22, $LBS_NOSEL)
Global $List14 = GUICtrlCreateList("", 240, 496, 41, 22, $LBS_NOSEL)
Global $List = GUICtrlCreateList("", 312, 112, 41, 22, $LBS_NOSEL)
Global $List16 = GUICtrlCreateList("", 312, 144, 41, 22, $LBS_NOSEL)
Global $List17 = GUICtrlCreateList("", 312, 176, 41, 22, $LBS_NOSEL)
Global $List18 = GUICtrlCreateList("", 312, 208, 41, 22, $LBS_NOSEL)
Global $List19 = GUICtrlCreateList("", 312, 240, 41, 22, $LBS_NOSEL)
Global $List20 = GUICtrlCreateList("", 312, 272, 41, 22, $LBS_NOSEL)
Global $List23 = GUICtrlCreateList("", 312, 304, 41, 22, $LBS_NOSEL)
Global $List24 = GUICtrlCreateList("", 312, 336, 41, 22, $LBS_NOSEL)
Global $List29 = GUICtrlCreateList("", 312, 368, 41, 22, $LBS_NOSEL)
Global $List30 = GUICtrlCreateList("", 312, 400, 41, 22, $LBS_NOSEL)
Global $List21 = GUICtrlCreateList("", 312, 432, 41, 22, $LBS_NOSEL)
Global $List15 = GUICtrlCreateList("", 312, 464, 41, 22, $LBS_NOSEL)
Global $List22 = GUICtrlCreateList("", 312, 496, 41, 22, $LBS_NOSEL)
Global $List34 = GUICtrlCreateList("", 376, 112, 41, 22, $LBS_NOSEL)
Global $List35 = GUICtrlCreateList("", 376, 144, 41, 22, $LBS_NOSEL)
Global $List36 = GUICtrlCreateList("", 376, 176, 41, 22, $LBS_NOSEL)
Global $List37 = GUICtrlCreateList("", 376, 208, 41, 22, $LBS_NOSEL)
Global $List38 = GUICtrlCreateList("", 376, 240, 41, 22, $LBS_NOSEL)
Global $List39 = GUICtrlCreateList("", 376, 272, 41, 22, $LBS_NOSEL)
Global $List25 = GUICtrlCreateList("", 376, 304, 41, 22, $LBS_NOSEL)
Global $List26 = GUICtrlCreateList("", 376, 336, 41, 22, $LBS_NOSEL)
Global $List31 = GUICtrlCreateList("", 376, 368, 41, 22, $LBS_NOSEL)
Global $List32 = GUICtrlCreateList("", 376, 400, 41, 22, $LBS_NOSEL)
Global $List40 = GUICtrlCreateList("", 376, 432, 41, 22, $LBS_NOSEL)
Global $List9 = GUICtrlCreateList("", 376, 464, 41, 22, $LBS_NOSEL)
Global $List10 = GUICtrlCreateList("", 376, 496, 41, 22, $LBS_NOSEL)
Global $Group2 = GUICtrlCreateGroup("Status Box", 488, 56, 433, 281)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel("Current Cycle #", 600, 88, 197, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List33 = GUICtrlCreateList("", 632, 136, 129, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 36, 400, 0, "MS Sans Serif")
Global $Label9 = GUICtrlCreateLabel("Test Time Counter", 584, 224, 241, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Label12 = GUICtrlCreateLabel("000:00:00", 614, 272, 188, 50)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $btnExit = GUICtrlCreateButton("Exit", 824, 16, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnFL = GUICtrlCreateButton("Failure Logs", 680, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnScr = GUICtrlCreateButton("Take ScreenShot", 496, 16, 139, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnZip = GUICtrlCreateButton("Zip testlog", 352, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $Group3 = GUICtrlCreateGroup("Message Box", 32, 544, 889, 145)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $msgbox = GUICtrlCreateEdit("", 56, 584, 601, 81, $ES_READONLY)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Label11 = GUICtrlCreateLabel("Count Down Timer", 706, 564, 183, 29, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List8 = GUICtrlCreateList("", 752, 600, 89, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $Group4 = GUICtrlCreateGroup("BMC SEL Counter - CONT0 / CONT1", 488, 352, 433, 185)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $bmcselcounter1 = GUICtrlCreateEdit("", 512, 384, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
Global $bmcselcounter2 = GUICtrlCreateEdit("", 512, 457, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Global $sTimer, $Dll_Timer, $hour, $min, $sec
Global $testDuration, $adlib, $begin

InitializeTimer() ; This function call should be included in the Switch...EndSwitch of the while loop

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    If $adlib Then
        $elapsedTime = GUICtrlRead($Label12)
        $hour = StringLeft($elapsedTime, 3)
        $min = StringMid($elapsedTime, 5, 2)
        $sec = StringRight($elapsedTime, 2)
        $elapsedSec = _TimeToTicks($hour, $min, $sec)/1000
        If $elapsedSec >= $testDuration Then
            AdlibUnRegister("SetTime")
            $adlib = False
            MsgBox(64, "", "Time's out", 3)
        EndIf
    EndIf
WEnd


Func InitializeTimer() ; This function is called by a GUI button
    $sInput = "000:00:10"  ; use GUICtrlRead() to get this user input
    $hour = StringLeft($sInput, 3)
    $min = StringMid($sInput, 5, 2)
    $sec = StringRight($sInput, 2)
    $testDuration = _TimeToTicks($hour, $min, $sec)/1000
 
    $begin = TimerInit()
    AdlibRegister("SetTime", 1000)
    $adlib = True
EndFunc

Func SetTime()
    Local $hour, $min, $sec
    _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
EndFunc

 

Edited by CYCho
Link to comment
Share on other sites

Hi @CYCho,

Thanks, I have modified my code as below.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Process.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>

#Region ### START Koda GUI section ### Form=c:\jacky\wugu\test tools\autoit3 codes\dashboard4.kxf
Global $Dashboard = GUICreate("Stress Test Dashboard v1.2 2019/09/06 (Developed by Flex TDC-SIT Jacky Lee)", 955, 708, 393, 78)
Global $Label1 = GUICtrlCreateLabel("Dashboard", 32, 8, 149, 36)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Group1 = GUICtrlCreateGroup("Counter", 32, 56, 433, 481)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("CONT0 BMC FRU Check", 56, 112, 153, 20)
Global $Label3 = GUICtrlCreateLabel("CONT1 BMC FRU Check", 56, 144, 153, 20)
Global $Label4 = GUICtrlCreateLabel("CONT0 BMC Sensor Check", 56, 176, 168, 20)
Global $Label5 = GUICtrlCreateLabel("CONT1 BMC Sensor Check", 56, 208, 168, 20)
Global $Label14 = GUICtrlCreateLabel("CONT0 BMC MC Info Check", 56, 240, 137, 20)
Global $Label15 = GUICtrlCreateLabel("CONT1 BMC MC Info Check", 56, 272, 137, 20)
Global $Label18 = GUICtrlCreateLabel("CONT0 BMC Self-Test Check", 56, 304, 179, 20)
Global $Label20 = GUICtrlCreateLabel("CONT1 BMC Self-Test Check", 56, 336, 179, 20)
Global $Label6 = GUICtrlCreateLabel("CONT0/1 LAN Port Ping Test", 56, 368, 187, 20)
Global $Label7 = GUICtrlCreateLabel("CONT0 BMC SEL NG Count", 56, 400, 187, 20)
Global $Label8 = GUICtrlCreateLabel("CONT1 BMC SEL NG Count", 56, 432, 176, 20)
Global $Label19 = GUICtrlCreateLabel("CONT0 Check Timeout Count", 56, 464, 179, 20)
Global $Label13 = GUICtrlCreateLabel("CONT1 Check Timeout Count", 56, 496, 179, 20)
Global $Label16 = GUICtrlCreateLabel("PASS", 240, 80, 44, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Label17 = GUICtrlCreateLabel("FAIL", 312, 80, 35, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $Label23 = GUICtrlCreateLabel("F/R (%)", 376, 80, 56, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x0078D7)
Global $List1 = GUICtrlCreateList("", 240, 112, 41, 22, $LBS_NOSEL)
Global $List2 = GUICtrlCreateList("", 240, 144, 41, 22, $LBS_NOSEL)
Global $List3 = GUICtrlCreateList("", 240, 176, 41, 22, $LBS_NOSEL)
Global $List4 = GUICtrlCreateList("", 240, 208, 41, 22, $LBS_NOSEL)
Global $List5 = GUICtrlCreateList("", 240, 240, 41, 22, $LBS_NOSEL)
Global $List6 = GUICtrlCreateList("", 240, 272, 41, 22, $LBS_NOSEL)
Global $List11 = GUICtrlCreateList("", 240, 304, 41, 22, $LBS_NOSEL)
Global $List12 = GUICtrlCreateList("", 240, 336, 41, 22, $LBS_NOSEL)
Global $List27 = GUICtrlCreateList("", 240, 368, 41, 22, $LBS_NOSEL)
Global $List28 = GUICtrlCreateList("", 240, 400, 41, 22, $LBS_NOSEL)
Global $List7 = GUICtrlCreateList("", 240, 432, 41, 22, $LBS_NOSEL)
Global $List13 = GUICtrlCreateList("", 240, 464, 41, 22, $LBS_NOSEL)
Global $List14 = GUICtrlCreateList("", 240, 496, 41, 22, $LBS_NOSEL)
Global $List = GUICtrlCreateList("", 312, 112, 41, 22, $LBS_NOSEL)
Global $List16 = GUICtrlCreateList("", 312, 144, 41, 22, $LBS_NOSEL)
Global $List17 = GUICtrlCreateList("", 312, 176, 41, 22, $LBS_NOSEL)
Global $List18 = GUICtrlCreateList("", 312, 208, 41, 22, $LBS_NOSEL)
Global $List19 = GUICtrlCreateList("", 312, 240, 41, 22, $LBS_NOSEL)
Global $List20 = GUICtrlCreateList("", 312, 272, 41, 22, $LBS_NOSEL)
Global $List23 = GUICtrlCreateList("", 312, 304, 41, 22, $LBS_NOSEL)
Global $List24 = GUICtrlCreateList("", 312, 336, 41, 22, $LBS_NOSEL)
Global $List29 = GUICtrlCreateList("", 312, 368, 41, 22, $LBS_NOSEL)
Global $List30 = GUICtrlCreateList("", 312, 400, 41, 22, $LBS_NOSEL)
Global $List21 = GUICtrlCreateList("", 312, 432, 41, 22, $LBS_NOSEL)
Global $List15 = GUICtrlCreateList("", 312, 464, 41, 22, $LBS_NOSEL)
Global $List22 = GUICtrlCreateList("", 312, 496, 41, 22, $LBS_NOSEL)
Global $List34 = GUICtrlCreateList("", 376, 112, 41, 22, $LBS_NOSEL)
Global $List35 = GUICtrlCreateList("", 376, 144, 41, 22, $LBS_NOSEL)
Global $List36 = GUICtrlCreateList("", 376, 176, 41, 22, $LBS_NOSEL)
Global $List37 = GUICtrlCreateList("", 376, 208, 41, 22, $LBS_NOSEL)
Global $List38 = GUICtrlCreateList("", 376, 240, 41, 22, $LBS_NOSEL)
Global $List39 = GUICtrlCreateList("", 376, 272, 41, 22, $LBS_NOSEL)
Global $List25 = GUICtrlCreateList("", 376, 304, 41, 22, $LBS_NOSEL)
Global $List26 = GUICtrlCreateList("", 376, 336, 41, 22, $LBS_NOSEL)
Global $List31 = GUICtrlCreateList("", 376, 368, 41, 22, $LBS_NOSEL)
Global $List32 = GUICtrlCreateList("", 376, 400, 41, 22, $LBS_NOSEL)
Global $List40 = GUICtrlCreateList("", 376, 432, 41, 22, $LBS_NOSEL)
Global $List9 = GUICtrlCreateList("", 376, 464, 41, 22, $LBS_NOSEL)
Global $List10 = GUICtrlCreateList("", 376, 496, 41, 22, $LBS_NOSEL)
Global $Group2 = GUICtrlCreateGroup("Status Box", 488, 56, 433, 281)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel("Current Cycle #", 600, 88, 197, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List33 = GUICtrlCreateList("", 632, 136, 129, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 36, 400, 0, "MS Sans Serif")
Global $Label9 = GUICtrlCreateLabel("Test Time Counter", 584, 224, 241, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Label12 = GUICtrlCreateLabel("000:00:00", 614, 272, 188, 50)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $btnExit = GUICtrlCreateButton("Exit", 824, 16, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnFL = GUICtrlCreateButton("Failure Logs", 680, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnScr = GUICtrlCreateButton("Take ScreenShot", 496, 16, 139, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnZip = GUICtrlCreateButton("Zip testlog", 352, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $Group3 = GUICtrlCreateGroup("Message Box", 32, 544, 889, 145)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $msgbox = GUICtrlCreateEdit("", 56, 584, 601, 81, $ES_READONLY)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Label11 = GUICtrlCreateLabel("Count Down Timer", 706, 564, 183, 29, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List8 = GUICtrlCreateList("", 752, 600, 89, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $Group4 = GUICtrlCreateGroup("BMC SEL Counter - CONT0 / CONT1", 488, 352, 433, 185)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $bmcselcounter1 = GUICtrlCreateEdit("", 512, 384, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
Global $bmcselcounter2 = GUICtrlCreateEdit("", 512, 457, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

If $CmdLine[1] = 1 Then
    Global $sTimer, $Dll_Timer, $hour, $min, $sec
    $begin = TimerInit()
    AdlibRegister("SetTime", 1000)
Else
    Global $testDuration, $adlib, $begin
    InitializeTimer()
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    If $CmdLine[1] = 1 Then
        If $adlib Then
            $elapsedTime = GUICtrlRead($Label12)
            $hour = StringLeft($elapsedTime, 3)
            $min = StringMid($elapsedTime, 5, 2)
            $sec = StringRight($elapsedTime, 2)
            $elapsedSec = _TimeToTicks($hour, $min, $sec)/1000
            If $elapsedSec >= $testDuration Then
                AdlibUnRegister("SetTime")
                $adlib = False
                MsgBox(64, "", "Time's out", 3)
            EndIf
        EndIf
    EndIf
WEnd

Func InitializeTimer() ; This function is called by a GUI button
    $sInput = "000:00:10"  ; use GUICtrlRead() to get this user input
    $hour = StringLeft($sInput, 3)
    $min = StringMid($sInput, 5, 2)
    $sec = StringRight($sInput, 2)
    $testDuration = _TimeToTicks($hour, $min, $sec)/1000

    $begin = TimerInit()
    AdlibRegister("SetTime", 1000)
    $adlib = True
EndFunc

Func SetTime()
    If $CmdLine[1] = 1 Then
        Global $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
        ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
    Else
        Local $hour, $min, $sec
        _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
        ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
    EndIf
EndFunc

As you can see that I have separated two time counter, one is with original code, which is used when user set test cycles as the test criteria, and user can understand how long time to perform all cycles test. The another one is that what I request here, for user to set test time as test criteria.

But, I got error message after I made the code to executable and execute it with single parameter "1" as the $CmdLine[1], but if with other number i.e. "2" then the script can be executed, but there is no msgbox pop up when 10 seconds reached, please advise what's the problem and how to fix it.

Thanks a lot !

Edited by jackylee0908
Link to comment
Share on other sites

If you want to have options of running this code with either a default, pre-determined time or a user-defined time, you can do it like this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Process.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>

#Region ### START Koda GUI section ### Form=c:\jacky\wugu\test tools\autoit3 codes\dashboard4.kxf
Global $Dashboard = GUICreate("Stress Test Dashboard v1.1 2019/08/22 (Developed by Flex TDC-SIT Jacky Lee)", 955, 708, 393, 78)
Global $Label1 = GUICtrlCreateLabel("Dashboard", 32, 8, 149, 36)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Group1 = GUICtrlCreateGroup("Counter", 32, 56, 433, 481)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("CONT0 BMC FRU Check", 56, 112, 153, 20)
Global $Label3 = GUICtrlCreateLabel("CONT1 BMC FRU Check", 56, 144, 153, 20)
Global $Label4 = GUICtrlCreateLabel("CONT0 BMC Sensor Check", 56, 176, 168, 20)
Global $Label5 = GUICtrlCreateLabel("CONT1 BMC Sensor Check", 56, 208, 168, 20)
Global $Label14 = GUICtrlCreateLabel("CONT0 BMC MC Info Check", 56, 240, 137, 20)
Global $Label15 = GUICtrlCreateLabel("CONT1 BMC MC Info Check", 56, 272, 137, 20)
Global $Label18 = GUICtrlCreateLabel("CONT0 BMC Self-Test Check", 56, 304, 179, 20)
Global $Label20 = GUICtrlCreateLabel("CONT1 BMC Self-Test Check", 56, 336, 179, 20)
Global $Label6 = GUICtrlCreateLabel("CONT0/1 LAN Port Ping Test", 56, 368, 187, 20)
Global $Label7 = GUICtrlCreateLabel("CONT0 BMC SEL NG Count", 56, 400, 187, 20)
Global $Label8 = GUICtrlCreateLabel("CONT1 BMC SEL NG Count", 56, 432, 176, 20)
Global $Label19 = GUICtrlCreateLabel("CONT0 Check Timeout Count", 56, 464, 179, 20)
Global $Label13 = GUICtrlCreateLabel("CONT1 Check Timeout Count", 56, 496, 179, 20)
Global $Label16 = GUICtrlCreateLabel("PASS", 240, 80, 44, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Label17 = GUICtrlCreateLabel("FAIL", 312, 80, 35, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $Label23 = GUICtrlCreateLabel("F/R (%)", 376, 80, 56, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x0078D7)
Global $List1 = GUICtrlCreateList("", 240, 112, 41, 22, $LBS_NOSEL)
Global $List2 = GUICtrlCreateList("", 240, 144, 41, 22, $LBS_NOSEL)
Global $List3 = GUICtrlCreateList("", 240, 176, 41, 22, $LBS_NOSEL)
Global $List4 = GUICtrlCreateList("", 240, 208, 41, 22, $LBS_NOSEL)
Global $List5 = GUICtrlCreateList("", 240, 240, 41, 22, $LBS_NOSEL)
Global $List6 = GUICtrlCreateList("", 240, 272, 41, 22, $LBS_NOSEL)
Global $List11 = GUICtrlCreateList("", 240, 304, 41, 22, $LBS_NOSEL)
Global $List12 = GUICtrlCreateList("", 240, 336, 41, 22, $LBS_NOSEL)
Global $List27 = GUICtrlCreateList("", 240, 368, 41, 22, $LBS_NOSEL)
Global $List28 = GUICtrlCreateList("", 240, 400, 41, 22, $LBS_NOSEL)
Global $List7 = GUICtrlCreateList("", 240, 432, 41, 22, $LBS_NOSEL)
Global $List13 = GUICtrlCreateList("", 240, 464, 41, 22, $LBS_NOSEL)
Global $List14 = GUICtrlCreateList("", 240, 496, 41, 22, $LBS_NOSEL)
Global $List = GUICtrlCreateList("", 312, 112, 41, 22, $LBS_NOSEL)
Global $List16 = GUICtrlCreateList("", 312, 144, 41, 22, $LBS_NOSEL)
Global $List17 = GUICtrlCreateList("", 312, 176, 41, 22, $LBS_NOSEL)
Global $List18 = GUICtrlCreateList("", 312, 208, 41, 22, $LBS_NOSEL)
Global $List19 = GUICtrlCreateList("", 312, 240, 41, 22, $LBS_NOSEL)
Global $List20 = GUICtrlCreateList("", 312, 272, 41, 22, $LBS_NOSEL)
Global $List23 = GUICtrlCreateList("", 312, 304, 41, 22, $LBS_NOSEL)
Global $List24 = GUICtrlCreateList("", 312, 336, 41, 22, $LBS_NOSEL)
Global $List29 = GUICtrlCreateList("", 312, 368, 41, 22, $LBS_NOSEL)
Global $List30 = GUICtrlCreateList("", 312, 400, 41, 22, $LBS_NOSEL)
Global $List21 = GUICtrlCreateList("", 312, 432, 41, 22, $LBS_NOSEL)
Global $List15 = GUICtrlCreateList("", 312, 464, 41, 22, $LBS_NOSEL)
Global $List22 = GUICtrlCreateList("", 312, 496, 41, 22, $LBS_NOSEL)
Global $List34 = GUICtrlCreateList("", 376, 112, 41, 22, $LBS_NOSEL)
Global $List35 = GUICtrlCreateList("", 376, 144, 41, 22, $LBS_NOSEL)
Global $List36 = GUICtrlCreateList("", 376, 176, 41, 22, $LBS_NOSEL)
Global $List37 = GUICtrlCreateList("", 376, 208, 41, 22, $LBS_NOSEL)
Global $List38 = GUICtrlCreateList("", 376, 240, 41, 22, $LBS_NOSEL)
Global $List39 = GUICtrlCreateList("", 376, 272, 41, 22, $LBS_NOSEL)
Global $List25 = GUICtrlCreateList("", 376, 304, 41, 22, $LBS_NOSEL)
Global $List26 = GUICtrlCreateList("", 376, 336, 41, 22, $LBS_NOSEL)
Global $List31 = GUICtrlCreateList("", 376, 368, 41, 22, $LBS_NOSEL)
Global $List32 = GUICtrlCreateList("", 376, 400, 41, 22, $LBS_NOSEL)
Global $List40 = GUICtrlCreateList("", 376, 432, 41, 22, $LBS_NOSEL)
Global $List9 = GUICtrlCreateList("", 376, 464, 41, 22, $LBS_NOSEL)
Global $List10 = GUICtrlCreateList("", 376, 496, 41, 22, $LBS_NOSEL)
Global $Group2 = GUICtrlCreateGroup("Status Box", 488, 56, 433, 281)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel("Current Cycle #", 600, 88, 197, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $List33 = GUICtrlCreateList("", 632, 136, 129, 70, $LBS_NOSEL)
GUICtrlSetData(-1, "0")
GUICtrlSetFont(-1, 36, 400, 0, "MS Sans Serif")
Global $Label9 = GUICtrlCreateLabel("Test Time Counter", 584, 224, 241, 36, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
Global $Label12 = GUICtrlCreateLabel("000:00:00", 614, 272, 188, 50)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
;Global $btnExit = GUICtrlCreateButton("Exit", 824, 16, 75, 25)
Global $btnGo = GUICtrlCreateButton("Go", 824, 16, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnFL = GUICtrlCreateButton("Failure Logs", 680, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnScr = GUICtrlCreateButton("Take ScreenShot", 496, 16, 139, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $btnZip = GUICtrlCreateButton("Zip testlog", 352, 16, 99, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Global $Group3 = GUICtrlCreateGroup("Message Box", 32, 544, 889, 145)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $msgbox = GUICtrlCreateEdit("", 56, 584, 601, 81, $ES_READONLY)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
;Global $Label11 = GUICtrlCreateLabel("Count Down Timer", 706, 564, 183, 29, $SS_CENTERIMAGE)
Global $Label11 = GUICtrlCreateLabel("User Input Time", 706, 564, 183, 29, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
;Global $List8 = GUICtrlCreateList("", 752, 600, 89, 70, $LBS_NOSEL)
;GUICtrlSetData(-1, "0")
;GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $UserInput = GUICtrlCreateInput("", 700, 600, 190, 50, $ES_CENTER)
GUICtrlSetData(-1, "0:0:0")
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
Global $Group4 = GUICtrlCreateGroup("BMC SEL Counter - CONT0 / CONT1", 488, 352, 433, 185)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Global $bmcselcounter1 = GUICtrlCreateEdit("", 512, 384, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
Global $bmcselcounter2 = GUICtrlCreateEdit("", 512, 457, 385, 65, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $testDuration, $begin

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $btnGo
            InitializeTimer()
    EndSwitch
WEnd


Func InitializeTimer() ; This function is called by a GUI button
    GUICtrlSetData($Label12, "000:00:00")
    $sInput = GUICtrlRead($UserInput)
    $hour = StringLeft($sInput, StringInStr($sInput, ":")-1)
    $sInput = StringMid($sInput, StringInStr($sInput, ":")+1)
    $min = StringLeft($sInput, StringInStr($sInput, ":")-1)
    $sec = StringMid($sInput, StringInStr($sInput, ":")+1)
    $testDuration = _TimeToTicks($hour, $min, $sec)/1000

    If $testDuration = 0 Then
        $testDuration = 10 ; the pre-detrmined test time in seconds
    EndIf

    $begin = TimerInit()
    AdlibRegister("SetTime", 1000)
EndFunc

Func SetTime()
    Local $hour, $min, $sec
    _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
    If TimerDiff($begin)/1000 > $testDuration Then
        AdlibUnRegister("SetTime")
        MsgBox(64, "", "Time's out", 3)
    EndIf
EndFunc

Just for demonstration purpose I changed your $btnExit to $btnGo and your $List8 to $UserInput. Test this code (click Go button) with different values of user input.  User input of "0:0:0" will result in pre-dtermined time.

Edited by CYCho
Link to comment
Share on other sites

Hi @CYCho,

Thanks, that really helps.

BTW, I am trying to put below timeout criteria into while loop, please advise how I can do?

If TimerDiff($begin)/1000 > $testDuration Then
        AdlibUnRegister("SetTime")
        MsgBox(64, "", "Time's out", 3)
    EndIf

For example, is the below code valid? I want to loop a test until the $testDuration is reached.

Func xxxx
    While TimerDiff($begin)/1000 < $testDuration
    <code>
    WEnd
    AdlibUnRegister("SetTime")
EndFunc

Thanks.

 

Update:

I have tried but doesn't work, it shows syntax error......

Global $testDuration, $begin

If $CmdLine[1] = 1 Then
    InitializeTimer(1)
    Test()
Else
    InitializeTimer(0)
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func Test()
    While TimerDiff($begin)/1000 < $testDuration Then
        ConsoleWrite("Time is on-going")
        Sleep(1000)
    WEnd
    AdlibUnRegister("SetTime")
    MsgBox(64, "", "Time's out", 3)
EndFunc

Func InitializeTimer($v1) ; This function is called by a GUI button
    GUICtrlSetData($Label12, "000:00:00")
    $sInput = "000:00:00"
    $hour = StringLeft($sInput, StringInStr($sInput, ":")-1)
    $sInput = StringMid($sInput, StringInStr($sInput, ":")+1)
    $min = StringLeft($sInput, StringInStr($sInput, ":")-1)
    $sec = StringMid($sInput, StringInStr($sInput, ":")+1)
    $testDuration = _TimeToTicks($hour, $min, $sec)/1000
    If $v1 = 1 Then
        $testDuration = $CmdLine[2] * 2
        $begin = TimerInit()
        AdlibRegister("SetTime", 1000)
    ElseIf $v1 = 0 Then
        $testDuration = 3596400
        $begin = TimerInit()
        AdlibRegister("SetTime", 1000)
    EndIf
EndFunc

Func SetTime()
    Local $hour, $min, $sec
    _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($Dashboard, "", $Label12, StringFormat("%03i:%02i:%02i", $hour, $min, $sec))
    If TimerDiff($begin)/1000 > $testDuration Then
        AdlibUnRegister("SetTime")
        MsgBox(64, "", "Time's out", 3)
    EndIf
EndFunc

 

Edited by jackylee0908
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...