Advertisement
Enlight432

Untitled

Jan 28th, 2025
39
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")  ; Ensure the cursor is made visible when the script exits.
  5.  
  6. SetTimer CheckMouse, 100
  7. CheckMouse() {
  8.     static hidden := false
  9.     if A_TimeIdleMouse > 2000 && !hidden
  10.         SystemCursor("Hide"), hidden := true
  11.     else if A_TimeIdleMouse < 2000 && hidden
  12.         SystemCursor("Show"), hidden := false
  13. }
  14.  
  15. SystemCursor(cmd)  ; cmd = "Show|Hide|Toggle|Reload"
  16. {
  17.     static visible := true, c := Map()
  18.     static sys_cursors := [32512, 32513, 32514, 32515, 32516, 32642
  19.                          , 32643, 32644, 32645, 32646, 32648, 32649, 32650]
  20.     if (cmd = "Reload" or !c.Count)  ; Reload when requested or at first call.
  21.     {
  22.         for i, id in sys_cursors
  23.         {
  24.             h_cursor  := DllCall("LoadCursor", "Ptr", 0, "Ptr", id)
  25.             h_default := DllCall("CopyImage", "Ptr", h_cursor, "UInt", 2
  26.                 , "Int", 0, "Int", 0, "UInt", 0)
  27.             h_blank   := DllCall("CreateCursor", "Ptr", 0, "Int", 0, "Int", 0
  28.                 , "Int", 32, "Int", 32
  29.                 , "Ptr", Buffer(32*4, 0xFF)
  30.                 , "Ptr", Buffer(32*4, 0))
  31.             c[id] := {default: h_default, blank: h_blank}
  32.         }
  33.     }
  34.     switch cmd
  35.     {
  36.     case "Show": visible := true
  37.     case "Hide": visible := false
  38.     case "Toggle": visible := !visible
  39.     default: return
  40.     }
  41.     for id, handles in c
  42.     {
  43.         h_cursor := DllCall("CopyImage"
  44.             , "Ptr", visible ? handles.default : handles.blank
  45.             , "UInt", 2, "Int", 0, "Int", 0, "UInt", 0)
  46.         DllCall("SetSystemCursor", "Ptr", h_cursor, "UInt", id)
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement