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