</head> <body> <h1>WinMove</h1> <p>指定したウィンドウの位置や大きさを変更します。</p> <pre class="Syntax"><span class="func">WinMove</span> <span class="optional">X, Y, Width, Height, WinTitle, WinText, ExcludeTitle, ExcludeText</span></pre> <h2 id="Parameters">パラメータ</h2> <dl> <dt>X, Y</dt> <dd> <p>型:<a href="../Concepts.htm#numbers">整数</a></p> <p>If either is omitted, the position in that dimension will not be changed. Otherwise, specify the X and Y coordinates (in pixels) of the upper left corner of the target window's new location. 画面左上のピクセルは0, 0にある。</p> </dd> <dt>Width, Height</dt> <dd> <p>型:<a href="../Concepts.htm#numbers">整数</a></p> <p>If either is omitted, the size in that dimension will not be changed. Otherwise, specify the new width and height of the window (in pixels).</p> </dd> <dt>WinTitle, WinText, ExcludeTitle, ExcludeText</dt> <dd> <p>型:<a href="../Concepts.htm#strings">文字列</a>、<a href="../Concepts.htm#numbers">整数</a>または<a href="../Concepts.htm#objects">オブジェクト</a></p> <p>もしこれらの項目が未設定または省略されたときは、<a href="../misc/WinTitle.htm#LastFoundWindow">最後に見つかったウィンドウ</a>が使用されます。そうでないときは、<em>WinTitle</em>に <a href="../misc/WinTitle.htm">ウィンドウタイトルまたはターゲットウィンドウを識別するための他の基準</a>、および/または<em>WinText</em>にターゲットウィンドウの単一のテキスト要素からの部分文字列(付属のWindow Spyユーティリティを使えばわかります)を指定します。</p> <p><em>ExcludeTitle</em>と<em>ExcludeText</em>はウィンドウのタイトルまたはテキストで除外するために使用します。指定の仕方は<em>WinTitle</em>と<em>WinText</em>に似ていますが、<em>ExcludeTitle</em>はウィンドウのタイトル以外の基準(ウィンドウクラスやHWNDなど)を認識しません。</p> <p>ウィンドウのタイトルとテキストは大文字と小文字を区別します。<a href="DetectHiddenWindows.htm">DetectHiddenWindows</a>関数 と <a href="DetectHiddenText.htm">DetectHiddenText</a>関数で変更しない限り、初期設定では非表示ウィンドウは検出されず、非表示テキストは検出されます。<a href="SetTitleMatchMode.htm">SetTitleMatchMode</a>関数で変更しない限り、初期設定ではウィンドウのタイトルはその中のどこかに<em>WinTitle</em>または<em>ExcludeTitle</em>を含んでいれば一致します。</p> </dd> </dl> <h2 id="Error_Handling">エラー処理</h2> <p>ウィンドウが見つからないときは、<a href="Error.htm#TargetError">TargetError</a>がスローされます。</p> <p>内部関数呼び出しが失敗を報告した場合、<a href="Error.htm#OSError">OSError</a>がスローされる。しかし、ウィンドウが自身の動きを制限している場合など、ウィンドウが動いていなくても成功が報告されることがある。</p> <h2 id="Remarks">備考</h2> <p>If <em>Width</em> or <em>Height</em> is small (or negative), most windows with a title bar will generally go no smaller than 112 x 27 pixels (however, some types of windows may have a different minimum size). If <em>Width</em> or <em>Height</em> is large, most windows will go no larger than approximately 12 pixels beyond the dimensions of the desktop.</p> <p>Negative X and Y coordinates are allowed to support multi-monitor systems and to move a window entirely off-screen.</p> <p>WinMoveは最小化されたウィンドウを移動することはできませんが、<a href="DetectHiddenWindows.htm">DetectHiddenWindows</a>がオンの場合、隠されたウィンドウを移動することができます。</p> <p>WinMoveの速度は<a href="SetWinDelay.htm">SetWinDelay</a>の影響を受ける。</p> <p>異なるDPI設定を持つ複数のスクリーンを持つシステムでは、<a href="../misc/DPIScaling.htm">OSのDPIスケーリング</a>により、ウィンドウの最終的な位置とサイズが要求された値と異なる場合があります。</p> <h2 id="Related">関連</h2> <p><a href="ControlMove.htm">ControlMove</a>、<a href="WinGetPos.htm">WinGetPos</a>、<a href="WinHide.htm">WinHide</a>、<a href="WinMinimize.htm">WinMinimize</a>、<a href="WinMaximize.htm">WinMaximize</a>、<a href="Win.htm">Win関数</a></p> <h2 id="Examples">例</h2> <div class="ex" id="ExLastFound"> <p><a class="ex_number" href="#ExLastFound"></a> 電卓を開き、電卓が存在するまで待ち、画面の左上隅に移動する。</p> <pre>Run "calc.exe" WinWait "Calculator" WinMove 0, 0 <em>; WinWait関数で見つかったウィンドウが対象となります。</em></pre> </div> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> クリップボードの内容を表示する固定サイズのポップアップウィンドウを作成し、画面の左上隅に移動する。</p> <pre>MyGui := Gui("ToolWindow -Sysmenu Disabled", "The clipboard contains:") MyGui.Add("Text",, A_Clipboard) MyGui.Show("w400 h300") WinMove 0, 0,,, MyGui MsgBox "Press OK to dismiss the popup window" MyGui.Destroy()</pre> </div> <div class="ex" id="ExCenter"> <p><a class="ex_number" href="#ExCenter"></a> 画面上のウィンドウを中央に配置する。</p> <pre>CenterWindow("ahk_class Notepad") CenterWindow(WinTitle) { WinGetPos ,, &amp;Width, &amp;Height, WinTitle WinMove (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2),,, WinTitle }</pre> </div> </body> </html>