- Local time
- 9:18 PM
- Posts
- 63
- OS
- Windows 11 23H2 Pro
This very simple tool uses the SystemParametersInfo API SystemParametersInfoW function (winuser.h) - Win32 apps to reload the cursors according to the data stored in the registry in HKCU\Control Panel\Cursors . If given a single numerical parameter on the command line, it will change the CursorBaseSize value as well, using an undocumented option with SystemParametersInfo API. The GUI for changing this is part of 'Accessibility > Mouse pointer and touch' in Settings. This also automatically writes and loads a new set of cursors. If you then use the mouse control panel, you can choose one of the default cursor sets and it will load at the CursorBaseSize you chose in Settings. Windows labels the sizes 1 (32) to 15 (256) in 16 steps of 16. So, 2 is CursorBaseSize of 48.
The cursors that Windows actually uses are a set of identically sized (mostly transparent) bitmaps. The pixel size of the bitmaps are set according to the CursorBaseSize and Windows scaling. Raymond Chen provides a small table at the end of What is the deal with the SM_CXCURSOR system metric? - The Old New Thing. If you are are using a CursorBaseSize other than 32 use your CursorBaseSize and the percentages. I use a 48 CursorBaseSize, and 150% scaling on a 27" 4k monitor, so my cursors are 72 x 72 bitmaps. Note that the scaling is in large increments. So, if you change your windows scaling from 100% to 125%, everything will be larger except your cursors.
The apparent size of the cursors you see depends on the size of the visible parts of the cursors in the bitmaps. So, for the Windows '(system scheme)' cursor sets you can choose between in the Mouse control panel, the (large) and (extra-large) variants are the same size bitmaps with larger images drawn in them.
Cursor files normally provide the same image at different pixel sizes. If the cursor file contains the exact size required it's used, if not Windows resizes to the required size. Most third party, and 'Windows' (system scheme)' cursor files contain 32, 48, 64, 96 and 128 sizes. So, they provide bitmaps of the required size with any scaling, providing the CursorBaseSize is 32. If you change the CursorBaseSize to something other than 32, you may get rescaled cursors. e.g. if you set CursorBaseSize to 48 with 100% scaling then standard cursor files will provide 48 pixel images required, if you are using 150% scaling they'll need to be resized to 72 pixel. If you set it to 40 they'll definitely be rescaled. The automatically generated cursors from 'Accessibility > Mouse pointer and touch' in Settings will have the optimum sizes. e.g. for 48 CursorBaseSize, they will be 48, 72, 96, 144 and 192. The maximum cursor size is 256, so no images above that size will be produced.
I mostly use this tool to reload cursors. From time to time after unlocking the system or switching users, the cursors are back to the default set, this reloads the correct ones from my profile. The resizing feature deliberately allows non standard sizes, which I've found useful for thinking about the actual cursor sizes I want, but it would be better to generate correctly sized cursors within the appropriate allowed CursorBaseSize. As supplied the program never produces any output on the command line. If you give an invalid command line argument, less than 32, more than 256, or not a number at all, then it acts as though you haven't supplied any argument, and simply reloads the cursors.
to compile the program save the source code, and from a terminal run:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /nologo resetCursors.cs
this should produce no messages, and an executable resetCursors.exe in the same directory. As this is a new unsigned executable file Windows will probably check it for viruses the first time you run it.
(attached as .txt file)
The cursors that Windows actually uses are a set of identically sized (mostly transparent) bitmaps. The pixel size of the bitmaps are set according to the CursorBaseSize and Windows scaling. Raymond Chen provides a small table at the end of What is the deal with the SM_CXCURSOR system metric? - The Old New Thing. If you are are using a CursorBaseSize other than 32 use your CursorBaseSize and the percentages. I use a 48 CursorBaseSize, and 150% scaling on a 27" 4k monitor, so my cursors are 72 x 72 bitmaps. Note that the scaling is in large increments. So, if you change your windows scaling from 100% to 125%, everything will be larger except your cursors.
The apparent size of the cursors you see depends on the size of the visible parts of the cursors in the bitmaps. So, for the Windows '(system scheme)' cursor sets you can choose between in the Mouse control panel, the (large) and (extra-large) variants are the same size bitmaps with larger images drawn in them.
Cursor files normally provide the same image at different pixel sizes. If the cursor file contains the exact size required it's used, if not Windows resizes to the required size. Most third party, and 'Windows' (system scheme)' cursor files contain 32, 48, 64, 96 and 128 sizes. So, they provide bitmaps of the required size with any scaling, providing the CursorBaseSize is 32. If you change the CursorBaseSize to something other than 32, you may get rescaled cursors. e.g. if you set CursorBaseSize to 48 with 100% scaling then standard cursor files will provide 48 pixel images required, if you are using 150% scaling they'll need to be resized to 72 pixel. If you set it to 40 they'll definitely be rescaled. The automatically generated cursors from 'Accessibility > Mouse pointer and touch' in Settings will have the optimum sizes. e.g. for 48 CursorBaseSize, they will be 48, 72, 96, 144 and 192. The maximum cursor size is 256, so no images above that size will be produced.
I mostly use this tool to reload cursors. From time to time after unlocking the system or switching users, the cursors are back to the default set, this reloads the correct ones from my profile. The resizing feature deliberately allows non standard sizes, which I've found useful for thinking about the actual cursor sizes I want, but it would be better to generate correctly sized cursors within the appropriate allowed CursorBaseSize. As supplied the program never produces any output on the command line. If you give an invalid command line argument, less than 32, more than 256, or not a number at all, then it acts as though you haven't supplied any argument, and simply reloads the cursors.
to compile the program save the source code, and from a terminal run:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /nologo resetCursors.cs
this should produce no messages, and an executable resetCursors.exe in the same directory. As this is a new unsigned executable file Windows will probably check it for viruses the first time you run it.
Code:
/* program to (re)set cursors after changing the cursor files, optionally to change the cursor base size
Windows uses 32, 48, 64 etc. You can use any value you like, but I suggest sticking to those values, as otherwise
Windows will have to rescale the cursors
*/
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Reflection;
// edit this if you change the program, so you know the compiled version is different
[assembly: AssemblyTitle("reset cursors, optionally change base size")]
[assembly: AssemblyCompany("skeptic Mike")]
[assembly: AssemblyProduct("resetCursors")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
namespace setCursors
{
class Program
{
[DllImport("user32.dll", SetLastError = true)]
static extern bool SystemParametersInfo(int uiAction, int uiParam, int pvParam, int fWinIni);
static void Main(string[] args)
{
const int SPI_SETCURSORS = 0x0057;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDCHANGE = 0x02;
// see https://stackoverflow.com/questions/60104778/change-and-update-the-size-of-the-cursor-in-windows-10-via-powershell/69687213#69687213
// for cursor size changing
int baseSize = 0;
int arg0 = 0;
if (args.Length == 1)
{
if (int.TryParse(args[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out arg0) && arg0 >= 32 && arg0 <= 256)
{
baseSize = arg0;
SystemParametersInfo(0x2029, 0, baseSize, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
}
SystemParametersInfo(SPI_SETCURSORS, 0, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
}
}
(attached as .txt file)
Attachments
My Computer
System One
-
- OS
- Windows 11 23H2 Pro
- Computer type
- PC/Desktop
- Manufacturer/Model
- MSI
- CPU
- i3-1215U
- Memory
- 8GB
- Monitor(s) Displays
- Dell S2721
- Screen Resolution
- 3840x2160
- PSU
- External 65W
- Keyboard
- Cherry mechanical (Blue)
- Mouse
- Microsoft
- Browser
- FireFox
- Antivirus
- MS