Advertisement
julioCCs

Simple hotkey press example

Jan 26th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.54 KB | None | 0 0
  1. $ON = False
  2.  
  3. $t = TimerInit()
  4.  
  5. func toggle()
  6.    $ON = not $ON
  7.    
  8.    $t = TimerInit()
  9. endfunc
  10.  
  11. func pressF2()
  12.    if TimerDiff($t) > 20000 then
  13.       ToolTip("Pressing F2...",10,10)
  14.      
  15.       send("{F2 down}")
  16.       Sleep(100)
  17.       send("{F2 up}")
  18.      
  19.       $t = TimerInit()
  20.    EndIf
  21. EndFunc
  22.  
  23. HotKeySet("0", "toggle")
  24.  
  25. MsgBox(0,"","Press 0 to toggle On/Off")
  26.  
  27. While True
  28.    Sleep(500)
  29.    
  30.    if $ON Then
  31.       ToolTip("Script ON: " & Round(TimerDiff($t)/1000,0),10,10)
  32.       pressF2()
  33.    Else
  34.       ToolTip("Script OFF...",10,10)
  35.    endif
  36. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement