Skip to content

Instantly share code, notes, and snippets.

@etigui
Created March 2, 2019 18:22
Show Gist options
  • Select an option

  • Save etigui/2cb7a81000b1307b8eb0266660fb7ba8 to your computer and use it in GitHub Desktop.

Select an option

Save etigui/2cb7a81000b1307b8eb0266660fb7ba8 to your computer and use it in GitHub Desktop.
Hide and show console
using ...;
namespace test {
class Program {
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_HIDE = 0;
const int SW_SHOW = 5;
private static void Main(string[] args) {
var handle = GetConsoleWindow();
// Hide
ShowWindow(handle, SW_HIDE);
// Show
//ShowWindow(handle, SW_SHOW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment