|
|
@ -414,60 +414,6 @@ namespace IPA |
|
|
|
Console.Write("\x1b[1A"); |
|
|
|
} |
|
|
|
|
|
|
|
[DllImport("kernel32.dll")] |
|
|
|
private static extern IntPtr GetConsoleWindow(); |
|
|
|
|
|
|
|
private static bool? isConsole; |
|
|
|
public static bool IsConsole |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
if (isConsole == null) |
|
|
|
isConsole = GetConsoleWindow() != IntPtr.Zero; |
|
|
|
return isConsole.Value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*internal static class Keyboard |
|
|
|
{ |
|
|
|
[Flags] |
|
|
|
private enum KeyStates |
|
|
|
{ |
|
|
|
None = 0, |
|
|
|
Down = 1, |
|
|
|
Toggled = 2 |
|
|
|
} |
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] |
|
|
|
private static extern short GetKeyState(int keyCode); |
|
|
|
|
|
|
|
private static KeyStates KeyState(Keys key) |
|
|
|
{ |
|
|
|
KeyStates state = KeyStates.None; |
|
|
|
|
|
|
|
short retVal = GetKeyState((int)key); |
|
|
|
|
|
|
|
//If the high-order bit is 1, the key is down
|
|
|
|
//otherwise, it is up.
|
|
|
|
if ((retVal & 0x8000) == 0x8000) |
|
|
|
state |= KeyStates.Down; |
|
|
|
|
|
|
|
//If the low-order bit is 1, the key is toggled.
|
|
|
|
if ((retVal & 1) == 1) |
|
|
|
state |= KeyStates.Toggled; |
|
|
|
|
|
|
|
return state; |
|
|
|
} |
|
|
|
|
|
|
|
public static bool IsKeyDown(Keys key) |
|
|
|
{ |
|
|
|
return KeyStates.Down == (KeyState(key) & KeyStates.Down); |
|
|
|
} |
|
|
|
|
|
|
|
public static bool IsKeyToggled(Keys key) |
|
|
|
{ |
|
|
|
return KeyStates.Toggled == (KeyState(key) & KeyStates.Toggled); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
public static bool IsConsole => Environment.UserInteractive; |
|
|
|
} |
|
|
|
} |