How to resize another program window?

How can I change another program - say, the size of the Skype window - from my program in C #?

+10
c # winapi
source share
3 answers

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 do not know the window pointer, you can use FindWindow .

It's also worth reading the MSDN SetWindowPos (very similar to MoveWindow).

+21
source share

You need to get the window handle of another program, use Process.MainWindowHandle or FindWindow .

After that, you can PInvoke SetWindowPos () to move, resize, change the position of the Z-order or min / max / restore window.

+4
source share

I would use Windows Api SetWindowPos

check this out: Using SetWindowPos in C # to move windows around

Of course, first you need to know the handle of the window you want to change, this can be done in different ways, for example, getting a process by name, then MainWindow of this process or using the EnumWindow or FindWindow API

0
source share

All Articles