Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- InstallMouseHook
- OnExit(*) => SystemCursor("Show")
- global lastX := 0
- global lastY := 0
- global lastMoveTime := A_TickCount
- global winKeyTime := -9999
- MouseGetPos(&lastX, &lastY)
- ~LWin::
- ~RWin::
- {
- global winKeyTime
- winKeyTime := A_TickCount
- }
- SetTimer CheckMouse, 10
- CheckMouse() {
- static hidden := false
- global lastX, lastY, lastMoveTime, winKeyTime
- MouseGetPos(&x, &y)
- dx := Abs(x - lastX)
- dy := Abs(y - lastY)
- if (dx > 3 || dy > 3) {
- if (hidden) {
- if (A_TickCount - winKeyTime > 300) {
- SystemCursor("Show")
- hidden := false
- }
- }
- lastMoveTime := A_TickCount
- } else {
- if (!hidden && (A_TickCount - lastMoveTime > 2000)) {
- SystemCursor("Hide")
- hidden := true
- }
- }
- lastX := x
- lastY := y
- }
- 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" || !c.Count) {
- 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(324, 0xFF)
- , "Ptr", Buffer(324, 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