@@ -22,7 +22,7 @@ internal static bool IsScreenReaderActive()
22
22
}
23
23
24
24
// TODO: Support Linux per https://code.visualstudio.com/docs/configure/accessibility/accessibility
25
- return false ;
25
+ return false ;
26
26
}
27
27
28
28
private static bool IsAnyWindowsScreenReaderEnabled ( )
@@ -32,31 +32,25 @@ private static bool IsAnyWindowsScreenReaderEnabled()
32
32
// doesn't detect the in-box Windows Narrator and is otherwise known
33
33
// to be problematic.
34
34
//
35
- // The following is adapted from the Electron project, under the MIT License.
36
- // Hence this is also how VS Code detects screenreaders.
37
- // See: https://github.com/electron/electron/pull/39988
38
-
39
- // Check for Windows Narrator using the NarratorRunning mutex
40
- if ( PlatformWindows . IsMutexPresent ( "NarratorRunning" ) )
35
+ // Unfortunately, the alternative method used by Electron and
36
+ // Chromium, where the relevant screen reader libraries (modules)
37
+ // are checked for does not work in the context of PowerShell
38
+ // because it relies on those applications injecting themselves into
39
+ // the app. Which they do not because it's not a windowed app, so
40
+ // we're stuck using the known-to-be-buggy way.
41
+ bool spiScreenReader = false ;
42
+ PlatformWindows . SystemParametersInfo ( PlatformWindows . SPI_GETSCREENREADER , 0 , ref spiScreenReader , 0 ) ;
43
+ if ( spiScreenReader )
44
+ {
41
45
return true ;
46
+ }
42
47
43
- // Check for various screen reader libraries
44
- string [ ] screenReaderLibraries = {
45
- // NVDA
46
- "nvdaHelperRemote.dll" ,
47
- // JAWS
48
- "jhook.dll" ,
49
- // Window-Eyes
50
- "gwhk64.dll" ,
51
- "gwmhook.dll" ,
52
- // ZoomText
53
- "AiSquared.Infuser.HookLib.dll"
54
- } ;
55
-
56
- foreach ( string library in screenReaderLibraries )
48
+ // At least we can correctly check for Windows Narrator using the
49
+ // NarratorRunning mutex (which is mostly not broken with
50
+ // PSReadLine, as it were).
51
+ if ( PlatformWindows . IsMutexPresent ( "NarratorRunning" ) )
57
52
{
58
- if ( PlatformWindows . IsLibraryLoaded ( library ) )
59
- return true ;
53
+ return true ;
60
54
}
61
55
62
56
return false ;
0 commit comments