Skip to content

Instantly share code, notes, and snippets.

@malteb247
Last active October 4, 2023 12:25
Show Gist options
  • Save malteb247/3139a14492b1728f6606473bf17267c1 to your computer and use it in GitHub Desktop.
Save malteb247/3139a14492b1728f6606473bf17267c1 to your computer and use it in GitHub Desktop.
Windows: Set cursor size via script.
<#
.SYNOPSIS
Sets pointer size
.DESCRIPTION
Can be used with e.g. desktop shortcuts to have a one-click solution
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command ".\Set-PointerSize.ps1 -Size 5"
.EXAMPLE
./Set-PointerSize.ps1 -Size 3
Sets the cursor size to 3
.EXAMPLE
./Set-PointerSize.ps1
Sets the pointer size to default (2)
#>
[CmdletBinding()]
param (
[Parameter()]
[int]
$Size = 2
)
$User32Signature = @'
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
uint pvParam,
uint fWinIni);
'@
$User32 = Add-Type -MemberDefinition $User32Signature -Name WinAPICall -Namespace SystemParamInfo -PassThru
$PvParam = 16 * $Size
Write-Debug "Setting pointer size to $Size ($PvParam)."
$User32::SystemParametersInfo(0x2029, 0, $PvParam, 0x01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment