首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重新启用导入模块Psreadline警告

重新启用导入模块Psreadline警告
EN

Stack Overflow用户
提问于 2021-03-22 14:53:40
回答 2查看 19.3K关注 0票数 14

此警告在Visual应用程序的终端中不断弹出。

代码语言:javascript
复制
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'.

即使我通过regedit将值更改为0,警告仍然显示。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-03-22 16:12:18

你的症状的含义是:

  • 窗口在PowerShell会话开始时处于屏幕读取器模式(用于视障人士的Windows可访问性功能)。
  • 您正在使用常规的 PowerShell session,无论是在控制台窗口中还是在Windows终端中,还是在Visual代码的集成终端中。
代码语言:javascript
复制
- By contrast, if you use Visual Studio Code _with the_ [_PowerShell extension_](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell), which enables a much richer PowerShell code-authoring experience, the problem doesn't occur, because the sessions provided by the extension in the so-called [_PowerShell Integrated Console_](https://stackoverflow.com/a/60132705/45375) do _not_ perform this check (as of version `2021.2.2`), and therefore _do_ load [`PSReadLine`](https://github.com/PowerShell/PSReadLine) (the module providing a rich command-line editing experience) and do not emit a warning. It is unclear if this unconditional override is by design or an oversight.
代码语言:javascript
复制
- While you _could_ follow the advice in the error message and add

Import-Module PSReadLine到您的$PROFILE文件并这样做将重新启用PSReadLine以获得丰富的命令行编辑体验,但是在启动时仍然会看到警告,因为在加载$PROFILE文件之前是由PowerShell发出的。尽管如此,如果在您的系统上通过设计启用屏幕阅读器模式,这是正确的解决方案。

如果此模式(意外地)通过persistently,注册中心()打开,则可以按以下方式关闭该模式:

代码语言:javascript
复制
Set-ItemProperty 'registry::HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access' On 0

Note

  • 此更改需要注销或重新引导才能生效。
  • 若要查询持久模式,请使用:
代码语言:javascript
复制
Get-ItemPropertyValue 'registry::HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access' On

如果此模式被某个应用程序意外地打开了in-OS-session,,因为该应用程序没有再次关闭该模式,或者在能够这样做之前已经崩溃,则可以临时编译C#代码来关闭该模式(感谢地从这个GitHub评论中修改),以便在同一OS用户会话中的未来 PowerShell会话不再看到警告。

代码语言:javascript
复制
(Add-Type -PassThru -Name ScreenReaderUtil -Namespace WinApiHelper -MemberDefinition @'
  const int SPIF_SENDCHANGE = 0x0002;
  const int SPI_SETSCREENREADER = 0x0047;

  [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
  private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);

  public static void EnableScreenReader(bool enable)
  {
    var ok = SystemParametersInfo(SPI_SETSCREENREADER, enable ? 1u : 0u, IntPtr.Zero, SPIF_SENDCHANGE);
    if (!ok)
    {
      throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
    }
  }
'@)::EnableScreenReader($false)
票数 20
EN

Stack Overflow用户

发布于 2022-10-31 14:23:34

你也可以试试这个(刚为我做的)

步骤1:打开"RUN“(WIN + R)步骤2:键入"regedit”步骤3:左侧有一个名为"HKEY_CURRENT_USER“的文件夹,单击第4步:单击名为的子文件夹”控制面板“,然后单击名为”盲访问“的子文件夹或遵循此路径

步骤5:右键单击选项" on ",选择“修改”选项,然后设置值0。

现在重启您的计算机和问题解决了:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66748513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档