【发布时间】:2020-02-06 22:55:23
【问题描述】:
我编写了下面的代码来影响(我认为)是负责 Windows 10 中光标和指针大小的唯一 reg 键。
这是我目前拥有的代码(里面还有一些额外的 cmets):
$RegConnect = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"CurrentUser", "$env:COMPUTERNAME")
$RegCursorsAccess = $RegConnect.OpenSubKey("Software\Microsoft\Accessibility", $true)
$RegCursorsControlPanel = $RegConnect.OpenSubKey("Control Panel\Cursors", $true)
# In the code below I'm trying to change the size of the cursor.
$RegCursorsControlPanel.SetValue("CursorBaseSize", 48)
$RegCursorsAccess.SetValue("CursorSize", 3)
$RegCursorsAccess.Close()
$RegConnect.Close()
# This section is where I thought it would update the cursor size.
# Here is where it lists stuff relating to setting and updating any settings changed.
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa
# SPI_SETCURSORS
# 0x0057
# Reloads the system cursors. Set the uiParam parameter to zero and the pvParam parameter to NULL.
$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(0x0057,0,$null,0)
它将更改注册表中的正确值。
因此,如果我运行此 PowerShell 代码,则易于访问设置中的鼠标大小处于正确的值。
但是光标没有更新。
如何在不注销并重新登录或重新启动机器的情况下强制更新。
以下是一些相关的 MS 链接:
SystemParametersInfoA function
编辑 - 一些附加信息
如果我运行 Process Monitor from Sysinternals 并深入挖掘,我可以在堆栈摘要下看到这一点。
这可能会导致比我更有知识的人找到如何更新鼠标大小。
HKCU\Control Panel\Cursors\(Default)部分SettingsHandlers_nt.dll
这也适用于可访问性部分。 Windows.UI.Accessibility.dll
这是我在 Process Monitors 过滤器中使用的设置,用于缩小项目范围。
【问题讨论】:
标签: powershell winapi