Ber*_*ken 12 powershell powershell-v7
在 Windows 10 上启动 PowerShell 7。
PowerShell 7.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.
Run Code Online (Sandbox Code Playgroud)
PowerShell 启动时不显示警告,因为我没有使用屏幕阅读器。
运行指定的命令Import-Module PSReadLine。自从我第一次想了解为什么会出现警告以来,我就没有运行过它。
$PSVersionTable 输出:Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Run Code Online (Sandbox Code Playgroud)
我安装了 Visual Studio 2017、2019
Ber*_*ken 15
设置以下注册表项:
Windows Registry
Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access\On
Run Code Online (Sandbox Code Playgroud)
值0并重新启动。
我通过@Znatz 提到的问题发现了这个替代解决方案。
小智 9
此错误有一个修复程序。
创建一个 .ps1 文件,粘贴以下代码并使用 powershell 运行它。
Add-Type -TypeDefinition '
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
public static class ScreenReaderFixUtil
{
public static bool IsScreenReaderActive()
{
var ptr = IntPtr.Zero;
try
{
ptr = Marshal.AllocHGlobal(sizeof(int));
int hr = Interop.SystemParametersInfo(
Interop.SPI_GETSCREENREADER,
sizeof(int),
ptr,
0);
if (hr == 0)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
return Marshal.ReadInt32(ptr) != 0;
}
finally
{
if (ptr != IntPtr.Zero)
{
Marshal.FreeHGlobal(ptr);
}
}
}
public static void SetScreenReaderActiveStatus(bool isActive)
{
int hr = Interop.SystemParametersInfo(
Interop.SPI_SETSCREENREADER,
isActive ? 1u : 0u,
IntPtr.Zero,
Interop.SPIF_SENDCHANGE);
if (hr == 0)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
private static class Interop
{
public const int SPIF_SENDCHANGE = 0x0002;
public const int SPI_GETSCREENREADER = 0x0046;
public const int SPI_SETSCREENREADER = 0x0047;
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int SystemParametersInfo(
uint uiAction,
uint uiParam,
IntPtr pvParam,
uint fWinIni);
}
}'
if ([ScreenReaderFixUtil]::IsScreenReaderActive()) {
[ScreenReaderFixUtil]::SetScreenReaderActiveStatus($false)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8009 次 |
| 最近记录: |