How do I change another program’s window’s size?

You can use MoveWindow (Where hWnd is the window you want to move):

[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

MoveWindow(ApplicationHandle, 600, 600, 600, 600, true);

If you don’t know the window pointer, you can use the FindWindow functionality.

Also worth a read is MSDN SetWindowPos (Very similar to MoveWindow).

Leave a Comment