以编程方式最大化一半屏幕上的窗口

我想在屏幕左侧最大化一个随机窗口。 我可以使用我的代码中的Windows Aerofunction吗? 这个窗口可以像鼠标一样最大化。 我只是想以编程的方式做到这一点。

我使用C# ,我可以得到窗口的IntPtr

如果可能的话,不要伪造鼠标或键盘input。

这可以在没有p / invoke的情况下完成。

尝试这个:

 Rectangle rect = Screen.PrimaryScreen.WorkingArea; rect.Width = rect.Width / 2; Bounds = rect; 

这将把当前窗口放在主屏幕的左侧。

然后,只需将其添加到屏幕的右侧。

 Location = new Point(rect.Width, 0); 

这不完全一样,但假货:

 ShowWindow(handle, SW_MAXIMIZE); // for a split second you might see a maximized window here MoveWindow(handle, 0, 0, Screen.PrimaryScreen.WorkingArea.Width / 2, Screen.PrimaryScreen.WorkingArea.Height, true);