Advertisement
Guest User

GPD Pocket Keys and Mouse

a guest
May 22nd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; RCtrl_stickscroll.ahk
  2. ;;
  3. ;; binds right ctrl to stick scroll like on thinkpads
  4. ;;
  5. ;; based on http://forum.notebookreview.com/threads/ultranav-middle-click-button-scroll.423415/
  6.  
  7. #SingleInstance force
  8. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  9. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  10.  
  11. #DEL::DEL
  12. #,::{
  13. #.::}
  14. DEL::BS
  15. +DEL::+DEL
  16. Capslock::a
  17. +Capslock::Capslock
  18. AppsKey::
  19.  
  20. ;; restore system cursors
  21. SPI_SETCURSORS := 0x57
  22. DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 )
  23.  
  24. KeyWait, AppsKey, T0.2
  25. If ErrorLevel = 1
  26. {
  27.   MouseGetPos, OriginX, OriginY
  28.   SystemCursor("Toggle")
  29.   SetTimer, WatchTheMouse, 5
  30.   KeyWait, AppsKey
  31.   SetTimer, WatchTheMouse, off
  32.   SystemCursor("On")
  33. }
  34. Else
  35.   ;; process momentary click
  36.   Send {AppsKey}
  37. return
  38.  
  39. WatchTheMouse:
  40.  MouseGetPos, NewX, NewY
  41.   dy := NewY-OriginY
  42.   dx := NewX-OriginX
  43.   If (dx**2 > 0 and dx**2>dy**2) ;edit 4 for sensitivity (changes sensitivity to movement)
  44.   {
  45.     times := Abs(dy)/4 ;edit 1 for sensitivity (changes frequency of scroll signal)
  46.     Loop, %times%
  47.     {
  48.       If (dx > 0)
  49.         Click WheelRight
  50.       Else
  51.         Click WheelLeft
  52.        }
  53.   }
  54.   If (dy**2 > 0 and dy**2>dx**2) ;edit 0 for sensitivity (changes sensitivity to movement)
  55.   {
  56.     times := Abs(dy)/4 ;edit 1 for sensitivity (changes frequency of scroll signal)
  57.     Loop, %times%
  58.     {
  59.       If (dy > 0)
  60.         Click WheelDown
  61.       Else
  62.         Click WheelUp
  63.     }  
  64.   }
  65.   MouseMove OriginX, OriginY
  66. return
  67.  
  68. SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
  69. {
  70.     static AndMask, XorMask, $, h_cursor
  71.         ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
  72.         , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
  73.         , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
  74.     if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
  75.     {
  76.         $ = h                                          ; active default cursors
  77.         VarSetCapacity( h_cursor,4444, 1 )
  78.         VarSetCapacity( AndMask, 32*4, 0xFF )
  79.         VarSetCapacity( XorMask, 32*4, 0 )
  80.         system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
  81.         StringSplit c, system_cursors, `,
  82.         Loop %c0%
  83.         {
  84.             h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
  85.             h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
  86.             b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
  87.                 , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
  88.         }
  89.     }
  90.     if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
  91.         $ = b  ; use blank cursors
  92.     else
  93.         $ = h  ; use the saved cursors
  94.  
  95.     Loop %c0%
  96.     {
  97.         h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
  98.         DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement