Created
July 9, 2015 15:28
-
-
Save eur0pa/5560f62a2807ba4c7b67 to your computer and use it in GitHub Desktop.
Resize NT window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class Win32 { | |
[DllImport("user32.dll")] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); | |
[DllImport("user32.dll")] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); | |
[DllImport("user32.dll")] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); | |
} | |
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 | |
} | |
"@ | |
$rcWindow = New-Object RECT | |
$rcClient = New-Object RECT | |
$h = (Get-Process | where {$_.MainWindowTitle -eq "Nuclear Throne"}).MainWindowHandle | |
[Win32]::GetWindowRect($h,[ref]$rcWindow) | |
[Win32]::GetClientRect($h,[ref]$rcClient) | |
$width = 640 | |
$height = 480 | |
$dx = ($rcWindow.Right - $rcWindow.Left) - $rcClient.Right | |
$dy = ($rcWindow.Bottom - $rcWindow.Top) - $rcClient.Bottom | |
[Win32]::MoveWindow($h, $rct.Left, $rct.Top, $width + $dx, $height + $dy, $true ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment