Skip to content

Commit

Permalink
Create WindowMover.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
shupershuff authored Aug 25, 2024
1 parent f6fd98c commit 8d7af6d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions WindowMover.ps1
Original file line number Diff line number Diff line change
@@ -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
}
"@

0 comments on commit 8d7af6d

Please sign in to comment.