/// <summary> /// 持续获取标准按键输入 /// </summary> public static bool GetKey(ConsoleKey keyCode) { if (!RunInBackground && Application.IsBackground) { return(false); } return((LowLevelAPI.GetAsyncKeyState((int)keyCode) & 0x8000) != 0); }
public static void UseStandardSetting() { IntPtr stdOutputHandle = LowLevelAPI.GetStdHandle(-11); LowLevelAPI.CONSOLE_FONT_INFO_EX fontInfo = new LowLevelAPI.CONSOLE_FONT_INFO_EX(); fontInfo.cbSize = (uint)Marshal.SizeOf(fontInfo); fontInfo.nFont = 0; fontInfo.dwFontSize.X = 20; fontInfo.dwFontSize.Y = 20; fontInfo.FaceName = "Consolas"; LowLevelAPI.SetCurrentConsoleFontEx(stdOutputHandle, true, ref fontInfo); }