powershellvisual-studio-codewarningsscreen-readers

Re enable Import Module Psreadline warning


This warning keeps popping in the terminal of Visual Code app

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'.

Even if I change the value to 0 via regedit, the warning still shows.


Solution

  • The implications of your symptom are:


    If this mode is (accidentally) turned on persistently, via the registry, you can turn it off as follows:

    Set-ItemProperty 'registry::HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access' On 0
    

    Note:

    Get-ItemPropertyValue 'registry::HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access' On
    

    If this mode has accidentally been turned on in-OS-session, by an application that is either ill-behaved in that it doesn't turn the mode back off again or has crashed before being able to do so, you can turn the mode off ad hoc so that future PowerShell sessions in the same OS user session no longer see the warning:

    The following, gratefully adapted from this GitHub comment, is a PowerShell command that does this via Add-Type and ad hoc-compiled C# code (which is necessary to perform P/Invoke calls):

    # Run in PowerShell
    (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)