说明
将按钮按下发送到连接的计算机。按下相当于单击并连续按住鼠标按钮。使用 Mouse.release() 取消印刷。
在使用 Mouse.press()
之前,您需要与 Mouse.begin() 开始通信。
Mouse.press()
默认为左键按下。
用法
Mouse.press()
Mouse.press(button)
参数
button
:按下哪个鼠标按钮。允许的数据类型:char
。
-
MOUSE_LEFT (default)
-
MOUSE_RIGHT
-
MOUSE_MIDDLE
返回
无
示例代码
#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 会接管您的鼠标!在使用该命令之前,请确保您有控制权。切换鼠标控制状态的按钮是有效的。
相关用法
- Arduino Mouse.begin()用法及代码示例
- Arduino Mouse.end()用法及代码示例
- Arduino Mouse.click()用法及代码示例
- Arduino Mouse.isPressed()用法及代码示例
- Arduino Mouse.release()用法及代码示例
- Arduino Mouse.move()用法及代码示例
- Arduino Mouse - Mouse.click()用法及代码示例
- Arduino Mouse - Mouse.press()用法及代码示例
- Arduino Mouse - Mouse.isPressed()用法及代码示例
- Arduino Mouse - Mouse.end()用法及代码示例
- Arduino Mouse - Mouse.begin()用法及代码示例
- Arduino Mouse - Mouse.move()用法及代码示例
- Arduino Mouse - Mouse.release()用法及代码示例
- Arduino MKRGSM - gprs.attachGPRS()用法及代码示例
- Arduino MKRGSM - sms.read()用法及代码示例
- Arduino MKRNB - getCurrentCarrier()用法及代码示例
- Arduino MKRWAN - available()用法及代码示例
- Arduino MKRNB - getIMEI()用法及代码示例
- Arduino MKRWAN - version()用法及代码示例
- Arduino MKRGSM - sms.print()用法及代码示例
- Arduino MKRNB - endSMS()用法及代码示例
- Arduino MKRGSM - client.connected()用法及代码示例
- Arduino MKRGSM - voice.answerCall()用法及代码示例
- Arduino MKRGSM - voice.hangCall()用法及代码示例
- Arduino MKRGSM - sms.write()用法及代码示例
注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 Mouse.press()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。