根据技术观察,用LLM辅助写了一个临时缓解措施脚本,注销/重启后失效。
建立一个新 powershell 脚本(*.ps1),把以下内容复制进去,保存,然后以管理员身份运行。
已在本地测试,有效。
# 鼠标指针临时修复脚本
# 用法:以管理员身份运行 PowerShell,执行此脚本
# 注意:注销或重启后需再次运行
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class CursorFix {
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr LoadImageW(
IntPtr hInstance,
string lpFileName,
uint uType,
int cxDesired,
int cyDesired,
uint fuLoad
);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SetSystemCursor(
IntPtr hcur,
uint id
);
}
"@
# Windows SDK winuser.h
$cursorMap = @{
"Arrow" = 32512 # IDC_ARROW
"IBeam" = 32513 # IDC_IBEAM
"Wait" = 32514 # IDC_WAIT
"Crosshair" = 32515 # IDC_CROSS
"UpArrow" = 32516 # IDC_UPARROW
"SizeNWSE" = 32642 # IDC_SIZENWSE
"SizeNESW" = 32643 # IDC_SIZENESW
"SizeWE" = 32644 # IDC_SIZEWE
"SizeNS" = 32645 # IDC_SIZENS
"SizeAll" = 32646 # IDC_SIZEALL
"No" = 32648 # IDC_NO
"Hand" = 32649 # IDC_HAND
"AppStarting" = 32650 # IDC_APPSTARTING
"Help" = 32651 # IDC_HELP
"Pin" = 32671 # IDC_PIN
"Person" = 32672 # IDC_PERSON
}
# 从注册表读取当前光标方案路径
$regPath = "HKCU:\Control Panel\Cursors"
$schemes = Get-ItemProperty -Path $regPath
Write-Host "Loading custom cursor file path from registry..." -ForegroundColor Cyan
$loadedCount = 0
$failedList = @()
foreach ($valueName in $cursorMap.Keys) {
$cursorPath = $schemes.$valueName
if ($cursorPath -and (Test-Path $cursorPath)) {
# 获取该注册表值对应的正确系统ID
$systemId = $cursorMap[$valueName]
try {
# 加载光标文件
# IMAGE_CURSOR = 2, LR_LOADFROMFILE = 0x0010
$hCursor = [CursorFix]::LoadImageW([IntPtr]::Zero, $cursorPath, 2, 0, 0, 0x0010)
if ($hCursor -ne [IntPtr]::Zero) {
# 应用光标
$result = [CursorFix]::SetSystemCursor($hCursor, $systemId)
if ($result) {
$loadedCount++
Write-Host " APPLIED: $valueName (ID:$systemId) -> $cursorPath" -ForegroundColor Green
} else {
$failedList += $valueName
Write-Host " FAILED: $valueName (ID:$systemId, ErrCode: $([System.Runtime.InteropServices.Marshal]::GetLastWin32Error()))" -ForegroundColor Red
}
} else {
$failedList += $valueName
Write-Host " FAILED TO LOAD: $valueName" -ForegroundColor Red
}
} catch {
$failedList += $valueName
Write-Host " EXCEPTION: $valueName - $_" -ForegroundColor Red
}
} else {
# 如果注册表里没有这个值(某些方案可能缺失),跳过
Write-Host " - SKIPPING: $valueName (undefined in registry)" -ForegroundColor Gray
}
}
Write-Host "`nCOMPLETE. $loadedCount / $($cursorMap.Count) cursors applied." -ForegroundColor Cyan
if ($failedList.Count -gt 0) {
Write-Host "WARNING:Failed to apply: $($failedList -join ', ')" -ForegroundColor Yellow
}
Write-Host "NOTICE:This is just a temporary mitigation and will be lost after logout or restart." -ForegroundColor Yellow