SetCursorScheme() : Changes cursor scheme

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

SetCursorScheme() : Changes cursor scheme

23 Oct 2020, 18:15

This function was requested in Ask for Help topic
 
SetCursorScheme(Scheme)
Parameter scheme can be one of the schemes returned by GetCursorSchemes()

Usage example:

Code: Select all

#NoEnv
#SingleInstance, Force

SetCursorScheme("Magnified")
Sleep 3000
SetCursorScheme("Windows Default") ; Windows 8.1 / 10
; SetCursorScheme("") ; Windows 7 / 8.1 / 10
Return
 

To apply (None) seen in the following dialog, call SetCursorScheme("")
I recommend using only SetCursorScheme("Windows Default") in Win 8.1 / Win 10
 
MousePropertiesDialog.png
MousePropertiesDialog.png (55.3 KiB) Viewed 2680 times
 
 
The functions:
 

Code: Select all

SetCursorScheme( Scheme )               { ; By SKAN on D3AO/D3AO @ tiny.cc/setcursorscheme
Local
  Cursors := "Arrow,Help,AppStarting,Wait,Crosshair,IBeam,NWPen,No,SizeNS,"
           . "SizeWE,SizeNWSE,SizeNESW,SizeAll,UpArrow,Hand,Pin,Person"

  SchemePath2 := "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cursors"
  SchemePath1 := "HKCU\Control Panel\Cursors"
  SetRegView, 64

  If ( Scheme="Windows Default" )
  {
      RegWrite, REG_SZ,    %SchemePath1%,, Windows Default
      RegWrite, REG_DWORD, %SchemePath1%, Scheme Source, 2
      Loop, Parse, Cursors, CSV
      {
          RegRead, Val, %SchemePath2%\Default, %A_LoopField%
          If (! ErrorLevel )
          RegWrite, REG_EXPAND_SZ, %SchemePath1%, %A_LoopField%, %Val%
      }

      SetRegView, Default
      Return DllCall("SystemParametersInfo", "Int",0x57, "Int", 0, "Ptr", 0, "Int", 0)
  }

  SchemeSource := 2
  RegRead, Val, %SchemePath2%\Schemes, %Scheme%

  If ( ErrorLevel )
  {
      SchemeSource := 1
      RegRead, Val, %SchemePath1%\Schemes, %Scheme%
  }

  If ( ErrorLevel )
      SchemeSource := 0,    Scheme := ""

  Cur := StrSplit(Val, ",")
  RegWrite, REG_DWORD, %SchemePath1%, Scheme Source, %SchemeSource%
  RegWrite, REG_SZ, %SchemePath1%,, %Scheme%

  Loop, Parse, Cursors, CSV
  {
      RegRead, Val, %SchemePath2%\Default, %A_LoopField%
      If (! ErrorLevel )
          RegWrite, REG_EXPAND_SZ, %SchemePath1%, %A_LoopField%, % Cur[A_Index]
  }

  SetRegView, Default
Return DllCall("SystemParametersInfo", "Int",0x57, "Int", 0, "Ptr", 0, "Int", 0)
}

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

GetCursorSchemes() {
Local Schemes := ""
  SetRegView, 64
  Loop, Reg
      , HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cursors\Schemes, V
   Schemes .= A_LoopRegName . "`n"
  Loop, Reg, HKCU\Control Panel\Cursors\Schemes, V
   Schemes .= A_LoopRegName . "`n"
  SetRegView, Default
Return RTrim(Schemes, "`n")
}

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
My Scripts and Functions: V1  V2
User avatar
elModo7
Posts: 217
Joined: 01 Sep 2017, 02:38
Location: Spain
Contact:

Re: SetCursorScheme() : Changes cursor scheme

26 Oct 2020, 14:01

Great for packing a temp scheme and loading it on app launch, unloading it on disconnect.
Ty for sharing!
rapp
Posts: 7
Joined: 22 May 2019, 23:19

Re: SetCursorScheme() : Changes cursor scheme

20 Feb 2022, 11:05

I am trying to change the mouse pointer color in connection with SetCursorScheme. The registry value for the mouse pointer color is changed, but the mouse pointer color is not changed. Any suggestions?

Code: Select all

SchemePath3 := "HKEY_USERS\[current user number hidden]\SOFTWARE\Microsoft\Accessibility"
RegWrite, REG_DWORD, %SchemePath3%, CursorColor, 0x000000FF  ; red
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: SetCursorScheme() : Changes cursor scheme

20 Feb 2022, 14:17

rapp wrote:
20 Feb 2022, 11:05
the mouse pointer color is changed, but the mouse pointer color is not changed. Any suggestions?
This might need a log-off/on or maybe a reboot.
LegzRwheelz
Posts: 56
Joined: 04 Nov 2019, 17:46

Re: SetCursorScheme() : Changes cursor scheme

05 Sep 2022, 03:54

THIS IS PHENOMENAL!!! Though I am wondering, I am not a noob any longer but not really "seasoned" ahk user so I have to ask a noobish question. Do I create an separate script called "Cursor Schemes" or whatever and place it in the libraries folder then at the top of my script add #Include Cursor Schemes?

Edit: I answered my own question and tried this and it works! I am so stoked. You eliminated multiple scripts for me by releasing this. Thank you so very much. :D

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 201 guests