I would like to open multiple console programs on my desktop. This is what I have to do everytime: 1.Right click Desktop->Screen resolution->Detect (4 monitors). 2.Open 16 different console programs (4 per screen). 3.Clicking on all windows to get the Z-order correctly. 3.Right click Taskbar->Show Windows Stacked (to organize all 16 windows to perfect squares, 4 on each screen in order of z-index).
Is there a way to do even just a part of this programmatically to help this go quicker?
You can use the windows API to move your console window. Use DllImport to declare the WinApi functions you want to use:
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
Then call them: e.g.
IntPtr ptr = GetConsoleWindow();
MoveWindow(ptr, 0, 0, 1000, 400, true);
You can use further WinApi function as SetWindowPos
. You can find the DllImport syntax by searching the web for PInvoke
and the name of the function. Follow the explanations there and in MSDN.
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