@@ -1680,35 +1680,6 @@ private void CreateRunspace(RunspaceCreationEventArgs runspaceCreationArgs)
16801680 }
16811681 }
16821682
1683- /// <summary>
1684- /// Check if a screen reviewer utility is running.
1685- /// When a screen reader is running, we don't auto-load the PSReadLine module at startup,
1686- /// since PSReadLine is not accessibility-friendly enough as of today.
1687- /// </summary>
1688- private bool IsScreenReaderActive ( )
1689- {
1690- if ( _screenReaderActive . HasValue )
1691- {
1692- return _screenReaderActive . Value ;
1693- }
1694-
1695- _screenReaderActive = false ;
1696- if ( Platform . IsWindowsDesktop )
1697- {
1698- // Note: this API can detect if a third-party screen reader is active, such as NVDA, but not the in-box Windows Narrator.
1699- // Quoted from https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-systemparametersinfoa about the
1700- // accessibility parameter 'SPI_GETSCREENREADER':
1701- // "Narrator, the screen reader that is included with Windows, does not set the SPI_SETSCREENREADER or SPI_GETSCREENREADER flags."
1702- bool enabled = false ;
1703- if ( SystemParametersInfo ( SPI_GETSCREENREADER , 0 , ref enabled , 0 ) )
1704- {
1705- _screenReaderActive = enabled ;
1706- }
1707- }
1708-
1709- return _screenReaderActive . Value ;
1710- }
1711-
17121683 private static bool LoadPSReadline ( )
17131684 {
17141685 // Don't load PSReadline if:
@@ -1759,7 +1730,6 @@ private void DoCreateRunspace(RunspaceCreationEventArgs args)
17591730 bool psReadlineFailed = false ;
17601731
17611732 // Load PSReadline by default unless there is no use:
1762- // - screen reader is active, such as NVDA, indicating non-visual access
17631733 // - we're running a command/file and just exiting
17641734 // - stdin is redirected by a parent process
17651735 // - we're not interactive
@@ -1770,26 +1740,18 @@ private void DoCreateRunspace(RunspaceCreationEventArgs args)
17701740 ReadOnlyCollection < ModuleSpecification > defaultImportModulesList = null ;
17711741 if ( ! customConfigurationProvided && LoadPSReadline ( ) )
17721742 {
1773- if ( IsScreenReaderActive ( ) )
1743+ // Create and open Runspace with PSReadline.
1744+ defaultImportModulesList = DefaultInitialSessionState . Modules ;
1745+ DefaultInitialSessionState . ImportPSModule ( new [ ] { "PSReadLine" } ) ;
1746+ consoleRunspace = RunspaceFactory . CreateRunspace ( this , DefaultInitialSessionState ) ;
1747+ try
17741748 {
1775- s_theConsoleHost . UI . WriteLine ( ManagedEntranceStrings . PSReadLineDisabledWhenScreenReaderIsActive ) ;
1776- s_theConsoleHost . UI . WriteLine ( ) ;
1749+ OpenConsoleRunspace ( consoleRunspace , args . StaMode ) ;
17771750 }
1778- else
1751+ catch ( Exception )
17791752 {
1780- // Create and open Runspace with PSReadline.
1781- defaultImportModulesList = DefaultInitialSessionState . Modules ;
1782- DefaultInitialSessionState . ImportPSModule ( new [ ] { "PSReadLine" } ) ;
1783- consoleRunspace = RunspaceFactory . CreateRunspace ( this , DefaultInitialSessionState ) ;
1784- try
1785- {
1786- OpenConsoleRunspace ( consoleRunspace , args . StaMode ) ;
1787- }
1788- catch ( Exception )
1789- {
1790- consoleRunspace = null ;
1791- psReadlineFailed = true ;
1792- }
1753+ consoleRunspace = null ;
1754+ psReadlineFailed = true ;
17931755 }
17941756 }
17951757
@@ -3102,7 +3064,6 @@ private sealed class ConsoleHostStartupException : Exception
31023064 private bool _setShouldExitCalled ;
31033065 private bool _isRunningPromptLoop ;
31043066 private bool _wasInitialCommandEncoded ;
3105- private bool ? _screenReaderActive ;
31063067
31073068 // hostGlobalLock is used to sync public method calls (in case multiple threads call into the host) and access to
31083069 // state that persists across method calls, like progress data. It's internal because the ui object also
0 commit comments