MouseClick

マウスのボタンをクリックまたは長押しするか、マウスのホイールを回転させます。注:The Click function is generally more flexible and easier to use.

MouseClick WhichButton, X, Y, ClickCount, Speed, DownOrUp, Relative

パラメータ

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). 事例:MouseClick "X1".

左はプライマリーボタン、右はセカンダリーボタンに対応します。ユーザーがシステム設定でボタンを入れ替えると、ボタンの物理的な位置は入れ替わりますが、効果は変わりません。

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は、ホイールを回すノッチの数です。

X, Y

型:整数

省略された場合は、カーソルの現在位置が使用されます。Otherwise, specify the X and Y coordinates to which the mouse cursor is moved prior to clicking. Coordinates are relative to the active window's client area unless CoordMode was used to change that.

ClickCount

型:整数

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

Speed

型:整数

省略された場合、デフォルトの速度(SetDefaultMouseSpeedで設定されたもの、またはそれ以外の2)が使用されることになります。Otherwise, specify the speed to move the mouse in the range 0 (fastest) to 100 (slowest). スピードを0にすると、マウスが瞬時に動きます。

SendInput/PlayモードではSpeedは無視され、マウスは瞬時に移動します(ただし、SetMouseDelayにはSendPlayに適用されるモードがあります)。To visually move the mouse more slowly -- such as a script that performs a demonstration for an audience -- use SendEvent "{Click 100 200}" or SendMode "Event" (optionally in conjuction with BlockInput).

DownOrUp

型:文字列

If blank or omitted, each click consists of a down-event followed by an up-event. そうでなければ、次の文字のうち、ひとつを指定してください。

D:マウスボタンを押しながら離さない(ダウンイベントを発生させます)。

U:マウスボタンを離す(つまりアップイベントを発生させます)。

Relative

型:文字列

If blank or omitted, the X and Y coordinates will be used for absolute positioning. Otherwise, specify the following letter:

R:X、Y座標は、現在のマウス位置からのオフセットとして扱われます。つまり、カーソルは現在位置から右にXピクセル(負の場合は左)、下にYピクセル(負の場合は上)だけ移動します。

備考

SendModeで設定された送信方式を使用します。

The Click function is recommended over MouseClick because it is generally easier to use. ただし、MouseClickはSpeedパラメータをサポートしていますが、Clickによる移動速度の調整はSetDefaultMouseSpeedを使用する必要があります。

シフトクリックやコントロールクリックを行うには、以下の例のように操作の前後に送信機能を使用します:

; Example #1: 
Send "{Control down}"
MouseClick "left", 55, 233
Send "{Control up}"
; Example #2:
Send "{Shift down}"
MouseClick "left", 55, 233
Send "{Shift up}"

SendPlayモードは、他のモードに比べ、より幅広いゲームにおいてマウスイベントを正常に発生させることができます。また、アプリケーションやゲームによっては、マウスの動きが速いと追従性が悪くなることがあります。speedパラメータまたはSetDefaultMouseSpeedを使用すると、速度を下げることができます(デフォルトのSendEventモードのみ)。

アプリケーションによっては、マウスホイールのClickCountが1以上でないと従わないものがあります。それらには、以下のようなLoopを使用します:

Loop 5
    MouseClick "WheelUp"

BlockInput関数を使用すると、ユーザーによる物理的なマウス操作が、マウス関数によって生成されるシミュレーションマウスイベントを妨害することを防ぐことができます。ただし、SendInput/Playモードでは、ユーザーの物理的なマウス操作を自動的に後回しにするため、一般にこの操作は必要ありません。

マウスのクリックダウンとクリックアップのたびに、自動的に遅延が発生します(SendInputモードとマウスホイールを回す場合を除く)。ディレイの長さを変更する場合は、SetMouseDelayを使用します。

CoordMode, SendMode, SetDefaultMouseSpeed, SetMouseDelay, Click, MouseClickDrag, MouseGetPos, MouseMove, ControlClick, BlockInput

現在のマウス位置でダブルクリックする。

MouseClick "left"
MouseClick "left"

Same as above.

MouseClick "left",,, 2

マウスカーソルを特定の位置に移動させ、右クリックを1回します。

MouseClick "right", 200, 300

マウスホイールの回転をシミュレートします。

#up::MouseClick "WheelUp",,, 2  ; Turn it by two notches.
#down::MouseClick "WheelDown",,, 2