Advertisement
Guest User

drag to scroll simple

a guest
May 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. XButton2:: ; this means forward button. to change this button you have to change this line and 1 other
  2.  
  3.     if !MouseControl
  4.     {
  5.         CoordMode Mouse, Screen     ; absolute coordinates
  6.         SetMouseDelay -1            ; fastest action
  7.         MouseGetPos x0, y0          ; get initial mouse pointer location
  8.         SetTimer WatchMouse, 1      ; run the subroutine fast (10..16ms)
  9.         MouseControl = 1
  10.     }
  11. Return
  12.  
  13.  
  14. WatchMouse: ; this is a loop
  15.  
  16.     GetKeyState,XB2state,XButton2,P ;and this one
  17.    
  18.     if (XB2state = "U")
  19.     {
  20.         SetTimer WatchMouse, off
  21.         MouseControl = 0
  22.     }
  23.  
  24.  
  25.     SetMouseDelay -1            ; fastest action                                Mouse gesture section
  26.     CoordMode Mouse, Screen     ; absolute coordinates
  27.     MouseGetPos x, y         ; get current mouse position
  28.  
  29.     Delta_x := abs(x-x0)
  30.     Delta_y := abs(y-y0)
  31.  
  32.     if (Delta_x > Delta_y) { ; to prevent 'double inputs',
  33.         if (x > x0)
  34.             R := 1
  35.         else R := 0
  36.         if (x < x0)
  37.             L := 1
  38.         else L := 0
  39.     }
  40.     else {
  41.         L := 0
  42.         R := 0
  43.     }
  44.  
  45.     if (Delta_y > Delta_x) {
  46.         if (y > y0)
  47.             D := 1
  48.         else D := 0
  49.         if (y < y0)
  50.             U := 1
  51.         else U := 0
  52.     }      
  53.     else {
  54.         D := 0
  55.         U := 0
  56.     }
  57.  
  58.     ;========================================= scrolling
  59.  
  60.  
  61.  
  62.  
  63.  
  64.     if (R && Delta_x > 1) {         ; right
  65.         send {WheelRight 1}
  66.     }
  67.     if (L && Delta_x > 1) {         ; left
  68.         send {WheelLeft 1}
  69.     }
  70.  
  71.     if (D && Delta_y > 1) {         ; down
  72.         send {WheelDown 1}
  73.     }
  74.     if (U && Delta_y > 1) {         ; up
  75.         send {WheelUp 1}
  76.     }
  77.     MouseMove x0, y0, 0         ; set mouse to original location
  78. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement