Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6.  
  7. suppressed:=0
  8. mhc_active:=1
  9. mstill:=0
  10. mWait:=200
  11. is_stopped:=1
  12. CoordMode, Mouse, Screen ; by default mouse coords are relative to window, but we want screen coords
  13. MouseGetPos, Ox, Oy
  14.  
  15.  
  16. ; letter keys suppress mouseclick timer
  17. Loop 25 {
  18.  
  19.  Hotkey, % "~" Chr(A_Index+96),Do_Suppress ; loop creating hotkeys for a-y
  20.  
  21. }
  22.  
  23. gosub Mouse_Check
  24.  
  25. return  ; end auto execute
  26.  
  27. ~z::   ; cancel current timer (there will be no click at this position)
  28.     global Ox
  29.     global Oy
  30.     MouseGetPos, Ox, Oy
  31.     global is_stopped
  32.     is_stopped:=1
  33.     global mstill
  34.     mstill:=0
  35.  
  36. Do_Suppress:
  37.     global mstill
  38.     mstill:=0
  39.     return
  40.  
  41. #v::   ; windowskey + v to toggle
  42.     global mhc_active
  43.     mhc_active:= mhc_active - 1
  44.     mhc_active:= mhc_active* (-1)
  45.  
  46. On_Mouse_Stopped:
  47.     MouseClick
  48.     return
  49.  
  50. !Esc::       ; Alt + Esc to quit
  51.     ExitApp
  52.  
  53. Mouse_Check:
  54.     global mhc_active
  55.     global suppressed
  56.     global mstill
  57.     global is_stopped
  58.     global Ox
  59.     global Oy
  60.     MouseGetPos, Ox, Oy
  61.     Sleep %mWait%
  62.     loop {
  63.         MouseGetPos, Mx, My
  64.         if( !winactive("ahk_class TaskSwitcherWnd") && !GetKeyState("LButton") && !GetKeyState("MButton")) {
  65.         if( Mx = Ox && My = Oy ) {
  66.             mStill++
  67.             if( mStill >= 5 ) {   ; 5 = 1000/mWait
  68.                 mStill:=0
  69.                 if( !is_stopped && mhc_active) {
  70.                     is_stopped:=1
  71.                     SetTimer, On_Mouse_Stopped, -1z
  72.                 }
  73.             }
  74.         } else  {
  75.            
  76.             is_stopped:=0
  77.             mstill:=0
  78.         }
  79.        
  80.         Ox:=Mx, Oy:=My
  81.         }
  82.         Sleep %mWait%
  83.     }
  84.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement