Advertisement
NJ5SkwAg

Multi Window AutoClicker

Nov 20th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SetControlDelay -1
  2. totalTimers := 0
  3.  
  4. ; add or subtract as many hotkeys as you'd like
  5. ; the first parameter of toggleTimer needs to be between 1 and maxTimers
  6. maxTimers := 3
  7. ; the second parameter is the delay between mouse clicks
  8. ; the third parameter is an optional flag that'll add holding down control as the mouse click is being sent
  9. f6:: toggleTimer(1, 90)
  10. f7:: toggleTimer(2, 2000, 1)
  11. f8:: toggleTimer(3, 75)
  12. ; hover over the window and place you want the mouse clicks to go then press the hotkey to start the clicks at that spot in that window
  13. f9:: pause ; pauses timers
  14. f10:: reload ; turns off timer
  15.  
  16. toggleTimer(timerID, timerInterval, lvl = 0)
  17. {
  18.     global
  19.     bTimer%timerID% := bTimer%timerID% ? false : true
  20.     if (bTimer%timerID%)
  21.     {
  22.         MouseGetPos X%timerID%, Y%timerID%, actWin%timerID%
  23.         timerInterval%timerID% := timerInterval
  24.         lvl%timerID% := lvl
  25.         prevTime%timerID% := 0
  26.         totalTimers++
  27.         if totalTimers = 1
  28.             SetTimer, timerLoop, -1
  29.     }
  30.     else
  31.         totalTimers--
  32. }
  33.  
  34. timerLoop:
  35.     loop
  36.     {
  37.         loop %maxTimers%
  38.         {
  39.             if (bTimer%A_Index% and A_TickCount - prevTime%A_Index% > timerInterval%A_Index%)
  40.             {
  41.                 if lvl%A_Index%
  42.                     ControlSend,, {ctrl down}, % "ahk_id " actWin%A_Index%
  43.                 ControlClick, % "x" X%A_Index% " y" Y%A_Index%, % "ahk_id " actWin%A_Index%,,,, NA
  44.                 if lvl%A_Index%
  45.                     ControlSend,, {ctrl up}, % "ahk_id " actWin%A_Index%
  46.                 prevTime%A_Index% := A_TickCount
  47.             }
  48.         }
  49.         if (!totalTimers)
  50.             return
  51.         sleep 1
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement