[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
引用C++,GetForegroundWindow获取当前电脑置顶应用,SetWindowPos(GetForegroundWindow(), 1, 0, 0, Screen.width, Screen.height, SWP_SHOWWINDOW);设置当前应用的窗口 hWndInsertAfter参数设置句柄,然后是设置大小和位置,最后设置Z顺序。
具体详情参考SetWindowPos 函数 (winuser.h) - Win32 apps | Microsoft Learn