ControlClick

マウスボタンまたはマウスホイールイベントをコントロールに送信します。

ControlClick Control-or-Pos, WinTitle, WinText, WhichButton, ClickCount, Options, ExcludeTitle, ExcludeText

パラメータ

Control-or-Pos

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

If omitted, the target window itself will be clicked. Otherwise, use one of the following modes.

Mode 1 (Position): Specify the X and Y coordinates relative to the upper left corner of the target window's client area. X座標はY座標の前にあり、その間に少なくとも1つのスペースまたはタブが必要です。事例:"X55 Y33". 指定された座標にコントロールがある場合、その正確な座標でクリックイベントを送信します。コントロールがない場合は、対象のウィンドウ自体にイベントが送られます(ウィンドウの性質によっては、何の効果もない場合もあります)。

Note: In mode 1, the X and Y option letters of the Options parameter are ignored.

Mode 2 (Control): Specify the control's ClassNN, text or HWND, or an object with a Hwnd property. For details, see The Control Parameter.

デフォルトでは、モード2がモード1より優先されます。For example, in the unlikely event that there is a control whose text or ClassNN has the format "Xnnn Ynnn", it would be acted upon by mode 2. これを上書きして無条件にモード1を使用するには、次の例のようにOptionsにPosという語を指定します。ControlClick "x255 y152", WinTitle,,,, "Pos".

WinTitle、WinText、ExcludeTitle、ExcludeText

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

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

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

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

WhichButton

型:文字列

If blank or omitted, it defaults to Left (the left mouse button). Otherwise, specify the button to click or the rotate/push direction of the mouse wheel.

Button: Left, Right, Middle (or just the first letter of each of these); or X1 (fourth button) or X2 (fifth button).

Mouse wheel: Specify WheelUp or WU to turn the wheel upward (away from you); specify WheelDown or WD to turn the wheel downward (toward you). ホイールを左に押す場合はWheelLeft(またはWL)、右に押す場合はWheelRight(またはWR)をそれぞれ指定します。ClickCountは、ホイールを回すノッチの数です。

ClickCount

型:整数

省略されたときは、初期値は 1 です。Otherwise, specify the number of times to click the mouse button or turn the mouse wheel.

Options

型:文字列

If blank or omitted, each click consists of a down-event followed by an up-event, and occurs at the center of the control when mode 2 is in effect. Otherwise, specify a series of one or more of the following options. 事例:"d x50 y25".

NA: May improve reliability. 以下の信頼性をご覧ください。

D:マウスボタンを押しながら離さない(ダウンイベントを発生させます)。If both the D and U options are absent, a complete click (down and up) will be sent.

U:マウスボタンを離す(つまりアップイベントを発生させます)。This option should not be present if the D option is already present (and vice versa).

Pos: Specify the word Pos anywhere in Options to unconditionally use the X/Y positioning mode as described in the Control-or-Pos parameter above.

Xn:Specify for n the X position to click at, relative to the control's upper left corner. 未指定の場合、クリックはコントロールの水平方向の中心で行われます。

Yn:Specify for n the Y position to click at, relative to the control's upper left corner. 未指定の場合、クリックはコントロールの垂直方向の中心で行われます。

Use decimal (not hexadecimal) numbers for the X and Y options.

エラー処理

以下の場合は例外が発生します。

Reliability

信頼性を高めるために、特にControlClick中にユーザーが物理的にマウスを動かしている場合、以下のどちらか、または両方が有効です。

1)ControlClickの前にSetControlDelay-1を使ってください。これにより、クリック中にマウスボタンを押し続けることがなくなり、ユーザーのマウスの物理的な動きによる干渉を軽減することができます。

2)以下のように、第6パラメータ(Options)の任意の場所に文字列NAを指定します。

SetControlDelay -1
ControlClick "Toolbar321", WinTitle,,,, "NA"

The NA option avoids marking the target window as active and avoids merging its input processing with that of the script, which may prevent physical movement of the mouse from interfering (but usually only when the target window is not active). ただし、この方法は、すべての種類のウィンドウやコントロールに有効とは限りません。

備考

すべてのアプリケーションが、マウスホイールの回転に対して1以上のClickCountを指定するわけではありません。For those applications, use a loop to turn the wheel more than one notch as in this example, which turns it 5 notches:

Loop 5
    ControlClick Control, WinTitle, WinText, "WheelUp"

SetControlDelay, Control functions, Click

OKボタンをクリックします。

ControlClick "OK"、"Some Window Title"

座標のセットでクリックします。XとYの間にコンマがないことに注意してください。

ControlClick "x55 y77", "Some Window Title"

NAモードでは、指定したコントロールからの相対座標でクリックします。

SetControlDelay -1  ; 信頼性を向上させ、副作用を低減させることができる。
ControlClick "Toolbar321", "Some Window Title",,,, "NA x192 y10"