Re enable Import Module Psreadline warning

Опубликовано: 27 Декабрь 2021
на канале: React Native Developer 2.0
18,616
93

Cause of Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes
type in cmd or Vs Code in TERMINAL

1)Set the following registry key:

Windows Registry
Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access\On
2) Get-Module PSReadLine
3)Import-Module PSReadLine
4)
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

public static class ScreenReaderFixUtil
{
public static bool IsScreenReaderActive()
{
var ptr = IntPtr.Zero;
try
{
ptr = Marshal.AllocHGlobal(sizeof(int));
int hr = Interop.SystemParametersInfo(
Interop.SPI_GETSCREENREADER,
sizeof(int),
ptr,
0);

if (hr == 0)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}

return Marshal.ReadInt32(ptr) != 0;
}
finally
{
if (ptr != IntPtr.Zero)
{
Marshal.FreeHGlobal(ptr);
}
}
}

public static void SetScreenReaderActiveStatus(bool isActive)
{
int hr = Interop.SystemParametersInfo(
Interop.SPI_SETSCREENREADER,
isActive ? 1u : 0u,
IntPtr.Zero,
Interop.SPIF_SENDCHANGE);

if (hr == 0)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}

private static class Interop
{
public const int SPIF_SENDCHANGE = 0x0002;

public const int SPI_GETSCREENREADER = 0x0046;

public const int SPI_SETSCREENREADER = 0x0047;

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

if ([ScreenReaderFixUtil]::IsScreenReaderActive()) {
[ScreenReaderFixUtil]::SetScreenReaderActiveStatus($false)
}





https://stackoverflow.com/questions/6...

https://serverfault.com/questions/101...
https://answers.microsoft.com/en-us/i...


Смотрите видео Re enable Import Module Psreadline warning онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал React Native Developer 2.0 27 Декабрь 2021. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 18,616 раз и оно понравилось 93 посетителям.