我已经导入了 SetWindowPos 和 GetForegroundWindow:
[DllImport("user32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Ansi)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, UInt32 uFlags);
我尝试使用它们,虽然 GetForegroundWindow 确实返回了一个有效值,但 SetWindowPos 没有做任何事情:
IntPtr hWID = GetForegroundWindow();
SetWindowPos(hWID, IntPtr.Zero, 50, 500, 800, 800, 0x0004);
我需要设置一些功能吗?还是我忘记了许可?
插入到 .NET 项目中的相同代码块似乎产生了想要的结果。有没有办法在 UWP 中实现这一点,还是我必须在 .NET 中做到这一点?