Here a solution which uses the window handle and an imported SetWindowPos() native function to achieve what you are looking for:
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace ConsoleWindowPos { static class Imports { public static IntPtr HWND_BOTTOM = (IntPtr)1; // public static IntPtr HWND_NOTOPMOST = (IntPtr)-2; public static IntPtr HWND_TOP = (IntPtr)0; // public static IntPtr HWND_TOPMOST = (IntPtr)-1; public static uint SWP_NOSIZE = 1; public static uint SWP_NOZORDER = 4; [DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, uint wFlags); } class Program { static void Main(string[] args) { var consoleWnd = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; Imports.SetWindowPos(consoleWnd, 0, 0, 0, 0, 0, Imports.SWP_NOSIZE | Imports.SWP_NOZORDER); System.Console.ReadLine(); } } }
The code moves the console window to the top left of your screen, not changing z-order nor changing width/height of the window.
HWND consoleWnd = GetConsoleWindow(); SetWindowPos(consoleWnd, .... );Now all you need to do is to see if you find functions with similar names in the .NET environment. Worst case, you still can call the native win32 functions.