From 8d7af6dd704428068085b95f2919c187e72124f2 Mon Sep 17 00:00:00 2001 From: shupershuff <63577525+shupershuff@users.noreply.github.com> Date: Sun, 25 Aug 2024 19:59:53 +1200 Subject: [PATCH] Create WindowMover.ps1 --- WindowMover.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 WindowMover.ps1 diff --git a/WindowMover.ps1 b/WindowMover.ps1 new file mode 100644 index 0000000..3fc4414 --- /dev/null +++ b/WindowMover.ps1 @@ -0,0 +1,25 @@ +Add-Type @" +using System; +using System.Runtime.InteropServices; +public class WindowAPI { + [DllImport("user32.dll")] //we have to import this Dynamic link library as this contains methods for getting and setting window locations. + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetWindowRect( //Used to get Window coordinates + IntPtr hWnd, out RECT lpRect); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public extern static bool MoveWindow( //Used to move windows + IntPtr handle, int x, int y, int width, int height, bool redraw); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetForegroundWindow(IntPtr hWnd); //Used to bring window to foreground :) +} +public struct RECT { + public int Left; // x position of upper-left corner + public int Top; // y position of upper-left corner + public int Right; // x position of lower-right corner + public int Bottom; // y position of lower-right corner +} +"@