0% found this document useful (0 votes)
226 views

Simple Way To Control Mouse Using Java Object in Matlab

This document describes a simple way to control a mouse using Java objects in MATLAB. It involves importing the Java Robot object, dynamically generating mouse coordinate functions, and using the mouseMove method to relocate the mouse according to the new coordinates over time. A demo code is provided that imports the Robot object, defines a function to calculate oscillating x-coordinates and keeps the y-coordinate centered, and uses mouseMove to relocate the mouse at each calculation step to make it move back and forth across the screen.

Uploaded by

Jans Hendry
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
226 views

Simple Way To Control Mouse Using Java Object in Matlab

This document describes a simple way to control a mouse using Java objects in MATLAB. It involves importing the Java Robot object, dynamically generating mouse coordinate functions, and using the mouseMove method to relocate the mouse according to the new coordinates over time. A demo code is provided that imports the Robot object, defines a function to calculate oscillating x-coordinates and keeps the y-coordinate centered, and uses mouseMove to relocate the mouse at each calculation step to make it move back and forth across the screen.

Uploaded by

Jans Hendry
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 1

[Jans Hendry / EE&IT UGM, Indonesia]

2011

SIMPLE WAY TO CONTROL MOUSE USING JAVA OBJECT IN MATLAB

Matlab also provide functions to control mouse moving automatically. One of them is by using Java object. Steps you have to follow are: Call Java Object (by importing Java Robot). Make dynamic coordinat for mouse. Command mouse to move according coordinat given.

See ?, this is very simple. Ok, below is a demo how to use this java object to control your mouse. 1. These code show you how to import java object.
%% importing java import java.awt.Robot; import java.awt.event.*; mouse=Robot; %%

2. I made dynamic function for relocating mouse coordinat. I hope you understand what this code does.
%% making coordinat and control mouse myscreen=get(0,'screensize'); x=myscreen(3); y=myscreen(4); for t=1:20:x coor=200*sin(t); pause(0.1); mouse.mouseMove(t,y/2+coor); end %% end

3. Above, you can see that i use mouse.mouseMove to relocate new coordinat for mouse. So your mouse will move according coordinat resulted from your function.

Im gonna prepare new program about how to move our mouse implementing function java object which controlled by catched object from webcam.
% originale % by jans hendry % EE&IT UGM, Indonesia

You might also like