Timers and Hotkey Example: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
No edit summary
 
m (Added AutoIt syntax highlight and Samples Category)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[Category:Samples]]
''Script by:'' scriptkitty
''Script by:'' scriptkitty


Line 9: Line 10:
''Notes:'' Not updated for current versions of AutoIt
''Notes:'' Not updated for current versions of AutoIt
   
   
<syntaxhighlight lang="autoit">
  winclose("mycountdown")
  winclose("mycountdown")
  AutoItWinSetTitle ( "mycountdown" )
  AutoItWinSetTitle ( "mycountdown" )
Line 65: Line 67:
  $loc=StringSplit($loc1,",")
  $loc=StringSplit($loc1,",")
  endfunc
  endfunc
</syntaxhighlight>
[[Category:Samples]]

Latest revision as of 02:51, 1 August 2013

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