ControlMove

コントロールを移動またはサイズ変更します。

ControlMove X, Y, Width, Height, Control, WinTitle, WinText, ExcludeTitle, ExcludeText

パラメータ

X, Y

型:整数

If either is omitted, the control's position in that dimension will not be changed. Otherwise, specify the X and Y coordinates (in pixels) of the upper left corner of the control's new location. The coordinates are relative to the upper-left corner of the target window's client area; ControlGetPos can be used to determine them.

幅、高さ

型:整数

If either is omitted, the control's size in that dimension will not be changed. Otherwise, specify the new width and height of the control (in pixels).

Control

型:文字列整数またはオブジェクト

コントロールのClassNN、text、HWND、またはHwndプロパティを持つオブジェクトを指します。詳しくは、「制御パラメータ」をご覧ください。

WinTitle、WinText、ExcludeTitle、ExcludeText

型:文字列整数またはオブジェクト

もしこれらの項目が未設定または省略されたときは、最後に見つかったウィンドウが使用されます。そうでないときは、WinTitleウィンドウタイトルまたはターゲットウィンドウを識別するための他の基準、および/またはWinTextにターゲットウィンドウの単一のテキスト要素からの部分文字列(付属のWindow Spyユーティリティを使えばわかります)を指定します。

ExcludeTitleExcludeTextはウィンドウのタイトルまたはテキストで除外するために使用します。指定の仕方はWinTitleWinTextに似ていますが、ExcludeTitleはウィンドウのタイトル以外の基準(ウィンドウクラスやHWNDなど)を認識しません。

ウィンドウのタイトルとテキストは大文字と小文字を区別します。DetectHiddenWindows関数 と DetectHiddenText関数で変更しない限り、初期設定では非表示ウィンドウは検出されず、非表示テキストは検出されます。SetTitleMatchMode関数で変更しない限り、初期設定ではウィンドウのタイトルはその中のどこかにWinTitleまたはExcludeTitleを含んでいれば一致します。

エラー処理

ウィンドウまたはコントロールが見つからないときは、TargetErrorがスローされます。

コントロールの現在位置を特定できなかった場合、OSErrorがスローされます。

備考

信頼性向上のため、この関数を実行するたびに自動的に遅延が発生します。この遅延は、SetControlDelayまたはA_ControlDelayに値を割り当てることで変更可能です。詳しくは、SetControlDelayの備考をご覧ください。

ControlGetPos, WinMove, SetControlDelay, Control functions

スクリプトがユーザーの入力を待っている間に、入力ボックスのOKボタンを操作する方法を説明します。

SetTimer ControlMoveTimer
IB := InputBox(, "My Input Box")

ControlMoveTimer()
{
    if !WinExist("My Input Box")
        return
    ; それ以外の場合は、"last found "ウィンドウを設定します。
    SetTimer , 0
    WinActivate
    ControlMove 10,, 200,, "OK"  ; OKボタンを左側に移動し、幅を広げる。
}