Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### Settings to Apply
- # The cursor scheme to apply (not used if scheme source is Windows Default)
- $CursorScheme = ""
- # 0 - Windows Default
- # 1 - User Scheme
- # 2 - System Scheme
- $CursorSchemeSource = 0
- # The uniform cursor size (default: 32x32 pixels)
- $CursorSize = 32
- #### Modify Registry
- Set-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name "(Default)" -Value $CursorScheme
- Set-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name "Scheme Source" -Value $CursorSchemeSource
- Set-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name "CursorBaseSize" -Value $CursorSize
- $schemeKeys = @(
- "Arrow", # Normal Select
- "Help", # Help Select
- "AppStarting", # Working in Background
- "Wait", # Busy
- "Crosshair", # Precision Select
- "IBeam", # Text Select
- "NWPen", # Handwriting
- "No", # Unavailable
- "SizeNS", # Vertical Resize
- "SizeWE", # Horizontal Resize
- "SizeNWSE", # Diagonal Resize 1
- "SizeNESW", # Diagonal Resize 2
- "SizeAll", # Move
- "UpArrow", # Alternate Select
- "Hand", # Link Select
- "Pin", # Location Select
- "Person" # Person Select
- )
- switch ($CursorSchemeSource) {
- 0 {
- $schemeValues = @()
- for ($i=0; $i -lt $schemeKeys.length; $i++) {
- $schemeValues += ""
- }
- }
- 1 {
- $schemeValues = (Get-Item -Path "HKCU:\Control Panel\Cursors\Schemes").GetValue(
- $CursorScheme, # registry key
- $null, # default value to return if not exist
- 'DoNotExpandEnvironmentNames' # options
- ).Split(',')
- }
- 2 {
- $schemeValues = (Get-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cursors\Schemes").GetValue(
- $CursorScheme, # registry key
- $null, # default value to return if not exist
- 'DoNotExpandEnvironmentNames' # options
- ).Split(',')
- }
- }
- for ($i=0; $i -lt $schemeKeys.length; $i++) {
- Set-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name $schemeKeys[$i] -Value $schemeValues[$i]
- }
- #### Notify Windows of Changes
- $SPI_SETCURSORS = 0x0057
- $SPI_SETCURSORSIZE = 0x2029 # supposedly undocumented, so i'll give it some name
- $SPIF_UPDATEINIFILE = 0x01
- $SPIF_SENDCHANGE = 0x02
- $CSharpSig = @'
- [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
- public static extern bool SystemParametersInfo(
- uint uiAction,
- uint uiParam,
- uint pvParam,
- uint fWinIni);
- '@
- $CursorRefresh = Add-Type -MemberDefinition $CSharpSig -Name WinAPICall -Namespace SystemParamInfo -PassThru
- $CursorRefresh::SystemParametersInfo($SPI_SETCURSORSIZE, 0, $CursorSize, $SPIF_UPDATEINIFILE);
- $CursorRefresh::SystemParametersInfo($SPI_SETCURSORS, 0, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE);
- ####
- Write-Host "Done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement