Mouse.press()

名称

Mouse.press()

説明

PCにマウス押下を送信する。これは、マウスボタンを押下したままにするのと等しい。押下状態はMouse.release()によってキャンセルされる。

Mouse.press()を使う前に、Mouse.begin()で通信を開始する必要がある。

Mouse.press()は、デフォルトでは、左ボタンを押下する。

書式

void Mouse_::press(uint8_t b = MOUSE_LEFT);

引数

bマウスのどのボタンを押すかを指定する。
MOUSE_LEFT:左ボタン(デフォルト)。
MOUSE_RIGHT:右ボタン。
MOUSE_MIDDLE:中ボタン。

戻り値

なし。

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <Mouse.h>

void setup() {
  //The switch that will initiate the Mouse press
  pinMode(2, INPUT);
  //The switch that will terminate the Mouse press
  pinMode(3, INPUT);
  //initiate the Mouse library
  Mouse.begin();
}

void loop() {
  //if the switch attached to pin 2 is closed, press and hold the left mouse button
  if (digitalRead(2) == HIGH) {
    Mouse.press();
  }
  //if the switch attached to pin 3 is closed, release the left mouse button
  if (digitalRead(3) == HIGH) {
    Mouse.release();
  }
}

注意

Mouse.press()コマンドを使うと、Arduinoはマウスを横取りする。このコマンドを使う前に制御可能であることを確認すること。マウス制御状態をトグルする押しボタンを使うのが効果がある。

参照

言語 Mouse.click()

言語 Mouse.end()

言語 Mouse.move()

言語 Mouse.release()

言語 Mouse.isPressed()

オリジナルのページ

https://www.arduino.cc/reference/en/language/functions/usb/mouse/mousepress/

Last Revision: 2019/02/21

実装の解析

まだ解析していません。

最終更新日

January 4, 2024

inserted by FC2 system