I have imported SetWindowPos and 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);
I have tried to use them, and while GetForegroundWindow does return a valid value, SetWindowPos does not do anything:
IntPtr hWID = GetForegroundWindow();
SetWindowPos(hWID, IntPtr.Zero, 50, 500, 800, 800, 0x0004);
Is there some capability I need to set? Or have I forgotten a permission?
It seems like the same block of code, inserted into a .NET project yields the wanted results. Is there a way to achieve this in UWP, or do I have to do this in .NET?