Mouse.release()

Last revision:2024/05/16

名称

Mouse.release()

説明

(Mouse.press()によって)前に押されたボタンを離すためのメッセージを送信する。

Mouse.release()は、デフォルトでは、左ボタンを離す。

書式

  • Mouse.release()
  • Mouse.release(button)

C言語シグネチャ(avr)

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

引数

buttonマウスのどのボタンを離すかを指定する。データ型: char
MOUSE_LEFT: 左ボタン(デフォルト)。
MOUSE_RIGHT: 右ボタン。
MOUSE_MIDDL: 中ボタン。

戻り値

なし。

コード例

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

参照

オリジナルのページ

https://docs.arduino.cc/language-reference/en/functions/usb/Mouse/mouseRelease/

実装の解析

まだ解析していません。

最終更新日

July 20, 2026

inserted by FC2 system