Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- InstallMouseHook
- OnExit (*) => SystemCursor("Show") ; Ensure the cursor is made visible when the script exits.
- SetTimer CheckMouse, 100
- CheckMouse() {
- static hidden := false
- if A_TimeIdleMouse > 2000 && !hidden
- SystemCursor("Hide"), hidden := true
- else if A_TimeIdleMouse < 2000 && hidden
- SystemCursor("Show"), hidden := false
- }
- SystemCursor(cmd) ; cmd = "Show|Hide|Toggle|Reload"
- {
- static visible := true, c := Map()
- static sys_cursors := [32512, 32513, 32514, 32515, 32516, 32642
- , 32643, 32644, 32645, 32646, 32648, 32649, 32650]
- if (cmd = "Reload" or !c.Count) ; Reload when requested or at first call.
- {
- for i, id in sys_cursors
- {
- h_cursor := DllCall("LoadCursor", "Ptr", 0, "Ptr", id)
- h_default := DllCall("CopyImage", "Ptr", h_cursor, "UInt", 2
- , "Int", 0, "Int", 0, "UInt", 0)
- h_blank := DllCall("CreateCursor", "Ptr", 0, "Int", 0, "Int", 0
- , "Int", 32, "Int", 32
- , "Ptr", Buffer(32*4, 0xFF)
- , "Ptr", Buffer(32*4, 0))
- c[id] := {default: h_default, blank: h_blank}
- }
- }
- switch cmd
- {
- case "Show": visible := true
- case "Hide": visible := false
- case "Toggle": visible := !visible
- default: return
- }
- for id, handles in c
- {
- h_cursor := DllCall("CopyImage"
- , "Ptr", visible ? handles.default : handles.blank
- , "UInt", 2, "Int", 0, "Int", 0, "UInt", 0)
- DllCall("SetSystemCursor", "Ptr", h_cursor, "UInt", id)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement