Advertisement
RyzaJr

[AHK] Hide.Mouse.Idle

Mar 28th, 2015
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This AHK script will hide your mouse cursor after 5 seconds
  2.  
  3. #NoTrayIcon
  4. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  5. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  6. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  7.  
  8.  
  9. SystemCursor("Init")
  10.  
  11. SetTimer, CheckIdle, 250
  12. return
  13.  
  14. CheckIdle:
  15. TimeIdle := A_TimeIdlePhysical // 1000
  16. if TimeIdle >= 5
  17. {
  18.     SystemCursor("Off")
  19. }
  20. else
  21. {
  22.     SystemCursor("On")
  23. }
  24. return
  25.  
  26. #Persistent
  27. OnExit, ShowCursor  ; Ensure the cursor is made visible when the script exits.
  28. return
  29.  
  30. ShowCursor:
  31. SystemCursor("On")
  32. ExitApp
  33.  
  34. SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
  35. {
  36.     static AndMask, XorMask, $, h_cursor
  37.         ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
  38.         , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
  39.         , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
  40.     if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
  41.     {
  42.         $ = h                                          ; active default cursors
  43.         VarSetCapacity( h_cursor,4444, 1 )
  44.         VarSetCapacity( AndMask, 32*4, 0xFF )
  45.         VarSetCapacity( XorMask, 32*4, 0 )
  46.         system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
  47.         StringSplit c, system_cursors, `,
  48.         Loop %c0%
  49.         {
  50.             h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
  51.             h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
  52.             b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
  53.                 , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
  54.         }
  55.     }
  56.     if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
  57.         $ = b  ; use blank cursors
  58.     else
  59.         $ = h  ; use the saved cursors
  60.  
  61.     Loop %c0%
  62.     {
  63.         h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
  64.         DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement