Created
August 12, 2012 16:44
-
-
Save t-mat/3332795 to your computer and use it in GitHub Desktop.
「ざくざくアクターズ」のウィンドウをリサイズする
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
# 「ざくざくアクターズ」のウィンドウをリサイズする、Powershell 用のスクリプト | |
Add-Type -Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
namespace ZakuZakuActorsHelper { | |
public static class Resize { | |
internal struct RECT { | |
public int left, top, right, bottom; | |
} | |
internal const int GWL_STYLE = -16; | |
internal const int GWL_EXSTYLE = -20; | |
[DllImport("user32.dll")] | |
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex); | |
[DllImport("user32.dll")] | |
internal static extern IntPtr GetMenu(IntPtr hWnd); | |
[DllImport("user32.dll")] | |
internal static extern int GetClientRect(IntPtr hWnd, out RECT lpRect); | |
[DllImport("user32.dll")] | |
internal static extern bool AdjustWindowRectEx(ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle); | |
[DllImport("user32.dll")] | |
internal static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect); | |
[DllImport("user32.dll")] | |
internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint); | |
public static void AdjustWindow(IntPtr hWnd, int tx) { | |
uint style = (uint) GetWindowLong(hWnd, GWL_STYLE); | |
uint exstyle = (uint) GetWindowLong(hWnd, GWL_EXSTYLE); | |
bool bMenu = GetMenu(hWnd) != IntPtr.Zero; | |
RECT rcClient = new RECT(); | |
GetClientRect(hWnd, out rcClient); | |
int w = (rcClient.right - rcClient.left); | |
int h = (rcClient.bottom - rcClient.top); | |
if(w > tx) { | |
w /= 4; | |
h /= 4; | |
} | |
rcClient.right = rcClient.left + w*2; | |
rcClient.bottom = rcClient.top + h*2; | |
AdjustWindowRectEx(ref rcClient, style, bMenu, exstyle); | |
w = rcClient.right - rcClient.left; | |
h = rcClient.bottom - rcClient.top; | |
RECT r = new RECT(); | |
GetWindowRect(hWnd, out r); | |
int cx = (r.left + r.right) / 2; | |
int cy = (r.top + r.bottom) / 2; | |
MoveWindow(hWnd, cx-w/2, cy-h/2, w, h, true); | |
} | |
} | |
} | |
"@ | |
$name = "game" | |
$widthThreshold = 800 | |
$hwnd = (Get-Process $name).MainWindowHandle | |
[ZakuZakuActorsHelper.Resize]::AdjustWindow($hwnd, $widthThreshold) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
メモ:リサイズ以前に、ゲーム内のウィンドウから文字がはみ出ている場合は、Windows側でフォント「VLゴシック」を消してみること。
Common Files以下にある自分のフォントを見にいきたいんだろうけど、ちゃんと読めてないぽい。