Fi0da Posted April 19, 2010 Posted April 19, 2010 In my studies in AutoItScript, reading about doubt tried to build a countdown as the code below:I would like to enable a hotkey to start but could not.Also like to understand how to make restart the timer after 00:00.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $countdown Global $inicio = 100000 Global $countdown = $inicio Global $start = TimerInit() Global $final = 0 Global $fcolour_toggle = True HotKeySet ("{PgUp}", "IntervalUp") HotKeySet ("{PgDn}", "IntervalDown") HotKeySet ("{Pause}","Stop") ;HotKeySet ("{End}","Start") $hGUI = GUICreate("", 120, 40, @DesktopWidth -1200, 750, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) $hLabel = GUICtrlCreateLabel("", 0, 0, 120, 20, BitOr($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-25, 0xFF8000) GUISetState() ;Func Start() While $countdown > 0 $countdown = $inicio - TimerDiff($start) Select Case $countdown < 30000 And $countdown > 29000 AdlibRegister("_Colour_Toggle", 250) Case $countdown < 60000 And $countdown > 59000 AdlibRegister("_Colour_Toggle",250) Case $countdown < 20000 And $countdown > 19000 AdlibRegister("_mousemove") Sleep (2000) EndSelect If Int($countdown / 1000) <> $final Then $final = Int ($countdown / 1000) $countdown = $inicio - TimerDiff($start) StarTimer() EndIf ; EndIf Sleep(100) Sleep (100) WEnd Func StarTimer() Local $iHours, $iMins, $iSecs _TicksToTime($countdown, $iHours, $iMins, $iSecs) GUICtrlSetData($hLabel, "Tempo Restante" & " " & $iMins & ":" & StringFormat("%02i", $iSecs)) EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _mousemove () MouseMove (400,500) Sleep (100) EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _Colour_Toggle() $fcolour_toggle = Not $fcolour_toggle If $fcolour_toggle Then GUICtrlSetBkColor($hLabel, 0xFFFF00) Else GUICtrlSetBkColor($hLabel, 0xFF8000) EndIf EndFunc func IntervalUp () $inicio = $inicio *1.1 EndFunc ; Func IntervalDown () $inicio = $inicio /1.1 EndFunc ; Func Stop () Exit EndFuncThanks For advance for teaching againI read ... I update ... I'm learning I read ... I update ... I learn ...
ForsakenGod Posted April 19, 2010 Posted April 19, 2010 (edited) if you want to let the script wait untill user input you have to just put in an loop to keep the script "alive" expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $countdown Global $inicio = 100000 Global $countdown = $inicio Global $start = TimerInit() Global $final = 0 Global $fcolour_toggle = True HotKeySet ("{PgUp}", "IntervalUp") HotKeySet ("{PgDn}", "IntervalDown") HotKeySet ("{Pause}","Stop") HotKeySet ("{End}","Start") $hGUI = GUICreate("", 120, 40, @DesktopWidth -1200, 750, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) $hLabel = GUICtrlCreateLabel("", 0, 0, 120, 20, BitOr($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-25, 0xFF8000) GUISetState() While 1 Sleep(100) Wend Func Start() While $countdown > 0 $countdown = $inicio - TimerDiff($start) Select Case $countdown < 30000 And $countdown > 29000 AdlibRegister("_Colour_Toggle", 250) Case $countdown < 60000 And $countdown > 59000 AdlibRegister("_Colour_Toggle",250) Case $countdown < 20000 And $countdown > 19000 AdlibRegister("_mousemove") Sleep (2000) EndSelect If Int($countdown / 1000) <> $final Then $final = Int ($countdown / 1000) $countdown = $inicio - TimerDiff($start) StarTimer() EndIf ; EndIf Sleep(100) Sleep (100) WEnd EndFunc Func StarTimer() Local $iHours, $iMins, $iSecs _TicksToTime($countdown, $iHours, $iMins, $iSecs) GUICtrlSetData($hLabel, "Tempo Restante" & " " & $iMins & ":" & StringFormat("%02i", $iSecs)) EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _mousemove () MouseMove (400,500) Sleep (100) EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _Colour_Toggle() $fcolour_toggle = Not $fcolour_toggle If $fcolour_toggle Then GUICtrlSetBkColor($hLabel, 0xFFFF00) Else GUICtrlSetBkColor($hLabel, 0xFF8000) EndIf EndFunc func IntervalUp () $inicio = $inicio *1.1 EndFunc ; Func IntervalDown () $inicio = $inicio /1.1 EndFunc ; Func Stop () Exit EndFunc Edit 1 : You were missing endfunc Edited April 19, 2010 by ForsakenGod
Fi0da Posted April 19, 2010 Author Posted April 19, 2010 Ok...ill try at home... And the question about restart the countdown after 00:00 ? Tkx for reply I read ... I update ... I learn ...
Fi0da Posted April 20, 2010 Author Posted April 20, 2010 (edited) Ok...it works when i press "End"... Now i wass read about the Automate Restart Countdow but not success . Anny reply is wellcome Edited April 20, 2010 by Fi0da I read ... I update ... I learn ...
Fi0da Posted April 21, 2010 Author Posted April 21, 2010 Hello.... I Wass tryed this... Case $countdown < 10000 And $countdown > 9900 Call ("StarTimer") Sleep (100) But not run...I duno how to do the timer restart. Anny Idea..someone???? I read ... I update ... I learn ...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now