Arduino Function: Mouse.click

Description

This function emulates the click of a mouse at the location of the cursor. Mouse.click() defaults to emulates the left mouse button.

Syntax

Mouse.click();
Mouse.click(button);

Parameters

button: which mouse button to press - char *MOUSE_LEFT (default) *MOUSE_RIGHT *MOUSE_MIDDLE

Returns

 none

Warning

When you use the Mouse.click() command, the Arduino takes over your mouse! Make sure you have control before you use the command. A pushbutton to toggle the mouse control state is effective.

Examples

void setup(){
  pinMode(2,INPUT);
  //initiate the Mouse library
  Mouse.begin();
}

void loop(){
  //if the button is pressed, send a Right mouse click
  if(digitalRead(2) == HIGH){
    Mouse.click();
  } 
}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc