WinGetPos

指定されたウィンドウの位置とサイズを取得

WinGetPos [, X, Y, Width, Height, WinTitle, WinText, ExcludeTitle, ExcludeText] 

Parameters

引数名説明
X, Y ウィンドウの水平座標と垂直座標を格納する変数名。
省略時はその項目は取得されない。
Width/Height ウィンドウの幅と高さを取得する変数名。
省略時はその項目は取得されない。
WinTitle ウィンドウタイトルなど。
ウィンドウ指定の方法参照。
WinText ウィンドウに含まれるテキスト
ExcludeTitle 除外タイトル
ExcludeText 除外テキスト

Remarks

条件に一致するウィンドウが存在しない場合、各変数は全て空になる。

WinTitleに「Program Manager」を指定すると、デスクトップのサイズを取得できる。
これはスクリーンのサイズと同じになる。
(シェルがExplorerの場合)

ウィンドウが最小化されている場合、XとYは「-32000」など(OSによっては違う可能性あり)になる。

Related

WinMove, ControlGetPos, WinGetActiveStats, WinGetActiveTitle, WinGetTitle, WinGetText, ControlGetText

Example(s)

WinGetPos, X, Y, Width, Height, Calculator
MsgBox, Calculator is at %X%`,%Y%

WinGetPos, X, Y, , , A  ; "A" to get the active window's pos.
MsgBox, The active window is at %X%`,%Y%

IfWinExist, Untitled - Notepad
{
	WinGetPos, Xpos, Ypos  ; Uses the window found above.
	MsgBox, Notepad is at %Xpos%`,%Ypos%
}