powershell - 通过 PowerShell 在 Windows 10 中更改和更新光标的大小
问题描述
我编写了下面的代码来影响(我认为)是负责 Windows 10 中光标和指针大小的唯一 reg 键。
这是我到目前为止的代码(里面有一些额外的评论):
$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 链接:
编辑 - 一些附加信息
如果我从 Sysinternals 运行 Process Monitor并深入挖掘,我可以在堆栈摘要下看到这一点。
这可能会导致比我更有知识的人找到如何更新鼠标大小。
该HKCU\Control Panel\Cursors\(Default)
部分SettingsHandlers_nt.dll
这也适用于可访问性部分。Windows.UI.Accessibility.dll
以下是我在 Process Monitors 过滤器中用于缩小项目范围的设置。
解决方案
因此,在使用作弊引擎对 SystemSettings.exe 进行了一些修改后,我发现了 MS 如何设置光标大小。它最终仍然使用 SystemParametersInfo 但带有一些未记录的参数。尝试以下方法:)
SystemParametersInfo(0x2029, 0, 16, 0x01);
将光标大小设置为 16。是的,您可以低于其最小值 32,一直到 1 :)
推荐阅读
- excel - 删除单元格中的重复单词
- java - 从 Saxon 转换中获取序列化属性
- java - Kotlin 对象创建和内存管理与 Java 的比较
- python - Python MySQL(MariaDB)查询 FROM_UNIXTIME 我得到计数而不是结果(显示行 0 - 0 )
- php - 如何根据三张表显示注册班级
- c++ - unique_ptr 的移动构造函数的实现问题
- python - 如何舍入所有列 Pandas 数据框?
- android - 删除 db-B 和 db-A 的公共子节点
- java - Spring Boot POST 请求在 Spring MVC 应用程序中不起作用
- php - 具有多文本值的搜索数组