我是一个初学者,我正在使用 Visual Studio Code,当我打开终端来运行 docker 所需的东西时(我正在使用 docker,不得不编写 docker-composer,因此无法工作)我收到:
`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'.`
我尝试将盲访问设置为 0,但它不起作用,顺便说一句,我不知道为什么即使我将其设置为 0,然后当我重新启动时再次出现在 1 上并且我被卡住了(我正在使用 docker 进行配置) 、postgresql 和 PGAdmin 在我的 Windows 11 上,ofc)。
我只想完成我的 docker-postgres 和 pgadmin 配置
在 Windows PowerShell ISE 中打开一个新脚本并输入以下内容:
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)
}``