Advertisement
Enlight432

Untitled

Jan 28th, 2025 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires AutoHotkey v2.0
  2. InstallMouseHook
  3.  
  4. OnExit(*) => SystemCursor("Show")
  5.  
  6. global lastX := 0
  7. global lastY := 0
  8. global lastMoveTime := A_TickCount
  9. global winKeyTime := -9999
  10.  
  11. MouseGetPos(&lastX, &lastY)
  12.  
  13. ~LWin::
  14. ~RWin::
  15. {
  16. global winKeyTime
  17. winKeyTime := A_TickCount
  18. }
  19.  
  20. SetTimer CheckMouse, 10
  21.  
  22. CheckMouse() {
  23. static hidden := false
  24. global lastX, lastY, lastMoveTime, winKeyTime
  25.  
  26. MouseGetPos(&x, &y)
  27.  
  28. dx := Abs(x - lastX)
  29. dy := Abs(y - lastY)
  30.  
  31. if (dx > 3 || dy > 3) {
  32.     if (hidden) {
  33.         if (A_TickCount - winKeyTime > 300) {
  34.             SystemCursor("Show")
  35.             hidden := false
  36.         }
  37.     }
  38.     lastMoveTime := A_TickCount
  39. } else {
  40.     if (!hidden && (A_TickCount - lastMoveTime > 2000)) {
  41.         SystemCursor("Hide")
  42.         hidden := true
  43.     }
  44. }
  45.  
  46. lastX := x
  47. lastY := y
  48. }
  49.  
  50. SystemCursor(cmd)  ; cmd = "Show|Hide|Toggle|Reload"
  51. {
  52. static visible := true, c := Map()
  53. static sys_cursors := [32512, 32513, 32514, 32515, 32516
  54. , 32642, 32643, 32644, 32645, 32646
  55. , 32648, 32649, 32650]
  56. if (cmd = "Reload" || !c.Count) {
  57. for i, id in sys_cursors {
  58. h_cursor  := DllCall("LoadCursor", "Ptr", 0, "Ptr", id)
  59. h_default := DllCall("CopyImage", "Ptr", h_cursor, "UInt", 2
  60. , "Int", 0, "Int", 0, "UInt", 0)
  61. h_blank   := DllCall("CreateCursor", "Ptr", 0, "Int", 0, "Int", 0
  62. , "Int", 32, "Int", 32
  63. , "Ptr", Buffer(324, 0xFF)
  64. , "Ptr", Buffer(324, 0))
  65. c[id] := {default: h_default, blank: h_blank}
  66. }
  67. }
  68. switch cmd {
  69. case "Show":
  70. visible := true
  71. case "Hide":
  72. visible := false
  73. case "Toggle":
  74. visible := !visible
  75. default:
  76. return
  77. }
  78. for id, handles in c {
  79. h_cursor := DllCall("CopyImage"
  80. , "Ptr", visible ? handles.default : handles.blank
  81. , "UInt", 2
  82. , "Int", 0
  83. , "Int", 0
  84. , "UInt", 0)
  85. DllCall("SetSystemCursor", "Ptr", h_cursor, "UInt", id)
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement