I have a Console Application app, I would like to minimize (not hide permanently) the Console when i run the app, is it possible? also, I am using a timer to run the task every 10 minutes, is it possible to minimize the console every time the app runs? thanks!
The following code should do the trick. Uses Win32 methods to minimize the console window. I am using Console.ReadLine() to prevent the window closing immediately.
internal class Program
{
[DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ShowWindow([In] IntPtr hWnd, [In] int nCmdShow);
private static void Main(string[] args)
{
IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;
ShowWindow(handle, 6);
Console.ReadLine();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With