Timers and Hotkey Example

From AutoIt Wiki
Revision as of 02:51, 1 August 2013 by Jaberwocky6669 (talk | contribs) (Added AutoIt syntax highlight and Samples Category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Script by: scriptkitty

Original Link: [1]

Description: This is just an example of a little quick timer you might have a use for. It uses variations of one button to do almost everything. I use it personally inside a game I play to keep track of stuff.

Notes: Not updated for current versions of AutoIt

 winclose("mycountdown")
 AutoItWinSetTitle ( "mycountdown" )
 $loc=StringSplit("546,378",","); default location
 $amount=90; default time
 HotKeySet ("!{NUMPADADD}","testoff")
 HotKeySet ("{NUMPADADD}","test")
 HotKeySet ("^{NUMPADADD}","amount")
 HotKeySet ("^!{NUMPADADD}","loc")
 ToolTip("Click + to start", 0, 0)
 sleep(2000)
 
 $begin=0
 While 1
 while $begin<>0
 ToolTip("", 0, 0)
 while (TimerStop($begin)/1000)<$amount
 $time=$amount-int(TimerStop($begin)/1000)/1
 if $time>120 then
 ToolTip(int($time/60)&" min left "&$time-int($time/60)*60&" seconds",$loc[1],$loc[2])
 else
 if $time<30 then
 ToolTip("Warning Warning Warning, Only "&$time&" seconds left ",$loc[1],$loc[2])
 else
 ToolTip($time&" seconds left ",$loc[1],$loc[2])
 endif
 endif
 
 sleep(20)
 wend
 wend
 ToolTip("", 0, 0)
 sleep(20)
 wend
 
 
 sleep(-1)
 
 func test()
 $begin = TimerStart()
 endfunc
 
 func testoff()
 ToolTip("")
 $begin = 0
 endfunc
 
 func amount()
 $amount = InputBox("Question", "How many sec?"&@crlf&"or XXmin", "1min", "", -1, -1, 0, 0)
 if stringinstr($amount,"min")>0 then $amount=int(stringreplace($amount,"min","")*60)
 return $amount
 endfunc
 
 func loc()
 $loc1 = InputBox("Question", "Location x,y?", "546,378", "", -1, -1, 0, 0)
 $loc=StringSplit($loc1,",")
 endfunc