Path: news.mathworks.com!not-for-mail
From: "Dan Haeg" <haegd@msoe.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to generate mouse clicks to the Operating System?
Date: Thu, 13 Sep 2007 05:10:33 +0000 (UTC)
Organization: Milwaukee School of Engineering
Lines: 30
Message-ID: <fcago9$fkk$1@fred.mathworks.com>
References: <fca6rr$mld$1@fred.mathworks.com>
Reply-To: "Dan Haeg" <haegd@msoe.edu>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1189660233 16020 172.30.248.37 (13 Sep 2007 05:10:33 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Sep 2007 05:10:33 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 475291
Xref: news.mathworks.com comp.soft-sys.matlab:428260



"Shane Brennan" <LoopUniverse+SPAM@gmail.com> wrote in
message <fca6rr$mld$1@fred.mathworks.com>...
> I am writing a program which tracks a laser light that is
> shined onto a wall. The code is able to track the laser
> fine, and I am able to recognize when the user "clicks" (by
> turning the laser off and on real quick). However, I do not
> know how to transmit this click information to the Operating
> System.
> 
> What I am wondering is, is there a MATLAB function or some
> other method I can use to generate a mouse click?


% create a robot
import java.awt.*;
import java.awt.event.*;
rob=Robot;
rob.mousePress(InputEvent.BUTTON1_MASK)%change button here
%may want a pause here
rob.mouseRelease(InputEvent.BUTTON1_MASK)%change button here

% to see more robot options
methodsview(rob);

I learned how to do this when I wanted to write a matlab
program to draw lines in linerider.

this site has more information about the robot
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html#mousePress(int)