We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Using Processing to control Mouse
Page Index Toggle Pages: 1
Using Processing to control Mouse? (Read 1186 times)
Using Processing to control Mouse?
Aug 21st, 2009, 8:38am
 
Hello,

I'm trying to create a touch surface using Frame Differencing. Is there an external or internal library that will give me access to the cursor (like a Wacom tablet)?

Thanks in advance,

--thesprucegoose
Re: Using Processing to control Mouse?
Reply #1 - Aug 22nd, 2009, 1:22am
 
You can use Robot() to control the mouse cursor.

Code:

robot Robot;

 try {
    robot = new Robot();
    robot.mouseMove(x,y);
 }
   catch (Exception e) {
   println("Can't Initialize the Robot");
 }



If you want to use mouse buttons you can use statements with these commands:

Left button

Code:
 robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);


Right button

Code:
 robot.mousePress(InputEvent.BUTTON2_MASK);
robot.mouseRelease(InputEvent.BUTTON2_MASK);
Page Index Toggle Pages: 1