Advertisement
Lorenzo501

Set Cursor To Loading Or Reset.ahk

Mar 4th, 2024 (edited)
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;could also just make it a toggle
  2. ;and when called in a WinHook, it seems to need SetTimer.. couldn't use SetCursor(false) otherwise
  3.  
  4. SetCursor(isLoadingApp)
  5. {
  6.     if (isLoadingApp)
  7.     {
  8.         cursors := Map("Arrow", 0, "Hand", 0, "Help", 0, "IBeam", 0, "NWPen", 0, "SizeAll", 0, "SizeNESW", 0, "SizeNS", 0, "SizeNWSE", 0, "SizeWE", 0)
  9.  
  10.         for (iteratedValueName in cursors)
  11.         {
  12.             cursors[iteratedValueName] := RegRead("HKEY_CURRENT_USER\Control Panel\Cursors", iteratedValueName)
  13.             RegWrite("%SYSTEMROOT%\Cursors\aero_working.ani", "REG_EXPAND_SZ", "HKEY_CURRENT_USER\Control Panel\Cursors", iteratedValueName)
  14.         }
  15.  
  16.         DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS := 0x0057, "UInt", 0, "Ptr", 0, "UInt", 0)
  17.  
  18.         for (iteratedValueName, iteratedCursorFilePath in cursors)
  19.             RegWrite(iteratedCursorFilePath, "REG_SZ", "HKEY_CURRENT_USER\Control Panel\Cursors", iteratedValueName)
  20.     }
  21.     else
  22.         DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS := 0x0057, "UInt", 0, "Ptr", 0, "UInt", 0)
  23. }
  24.  
  25. /*************************************************************
  26.  * To reset cursors in registry use "Default cursors.reg"
  27.  * and then invoke DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS := 0x0057, "UInt", 0, "Ptr", 0, "UInt", 0)
  28.  *************************************************************
  29. Windows Registry Editor Version 5.00
  30.  
  31. [HKEY_CURRENT_USER\Control Panel\Cursors]
  32. "Arrow"="C:\\WINDOWS\\cursors\\aero_arrow.cur"
  33. "Hand"="C:\\WINDOWS\\cursors\\aero_link.cur"
  34. "Help"="C:\\WINDOWS\\cursors\\aero_helpsel.cur"
  35. "IBeam"=""
  36. "NWPen"="C:\\WINDOWS\\cursors\\aero_pen.cur"
  37. "SizeAll"="C:\\WINDOWS\\cursors\\aero_move.cur"
  38. "SizeNESW"="C:\\WINDOWS\\cursors\\aero_nesw.cur"
  39. "SizeNS"="C:\\WINDOWS\\cursors\\aero_ns.cur"
  40. "SizeNWSE"="C:\\WINDOWS\\cursors\\aero_nwse.cur"
  41. "SizeWE"="C:\\WINDOWS\\cursors\\aero_ew.cur"
  42. */
  43.  
  44. /********** TRASH: loading cursor without animation **********/
  45.  
  46. /*cursors := [32512, 32513, 32514, 32515, 32516, 32642, 32643, 32644, 32645, 32646, 32648, 32649, 32650]
  47. OnExit((*) => (DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS := 0x0057, "UInt", 0, "Ptr", 0, "UInt", 0), 0)) ; Lambda returns last value (non-zero avoids exit)
  48.  
  49. for (id in cursors)
  50.     DllCall("SetSystemCursor", "Ptr", DllCall("CopyIcon", "Ptr", DllCall("LoadCursor", "Ptr", 0, "Ptr", IDC_APPSTARTING := 32650)), "UInt", id)*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement