provide-free-support Ujjwal's Blog: Control your mouse with Java

Monday, July 1, 2013

Control your mouse with Java

Perform all mouse operation with help of java program
You may control your mouse using this simple program.
import java.awt.Robot; 
import java.awt.event.InputEvent; 

/* 
 * To change this template, choose Tools | Templates 
 * and open the template in the editor. 
 */ 
/** 
 * 
 * @author Anurag 
 */ 
public class ControlMouse { 

    public static void main(String args[]) { 
        ControlMouse.control_mouse(); 
    } 

    public static void control_mouse() { 
        try { 
            Robot robot = new Robot(); 
             
            //Move mouse to cordinates x,y 
            robot.mouseMove(300, 550); 
             
            // Perform mouse LEFT CLICK 
            robot.mousePress(InputEvent.BUTTON1_MASK); 
            robot.mouseRelease(InputEvent.BUTTON1_MASK); 
             
            // Perform mouse RIGHT CLICK 
            robot.mousePress(InputEvent.BUTTON3_MASK); 
            robot.mouseRelease(InputEvent.BUTTON3_MASK); 
             

            // SCROLL THE MOUSE WHEEL 
            robot.mouseWheel(-150); 
             
        } catch (Exception e) { 
            e.printStackTrace(); 
        } 
    } 

Explaination :
First we make an object of Robot class.
To move the mouse to particular position like x,y use robot.mouseMove(x,y)
To perform left click just perform mouse press and then release operation. For this we use mousePress and mouseRelease methods.BUTTON1_MASK resembles the left button
To perform right click just perform mouse press and then release operation. For this we use mousePress and mouseRelease methods.BUTTON3_MASK resembles the right button
To move mouse wheel use robot.mouseWheel(-150). Here -ve value give upward mouse wheel movement and +ve show downward.
Hope you liked it.. :) 
Cheers,

Ujjwal Soni

No comments:

best-it-exam-    | for-our-work-    | hottst-on-sale-    | it-sale-    | tast-dumps-us-    | test-king-number-    | pass-do-it-    | just-do-it-    | pass-with-us-    | passresults-everything-    | passtutor-our-dumps-    | realtests-us-exam-    | latest-update-source-for-    | cbtnuggets-sale-exam    | experts-revised-exam    | certguide-sale-exam    | test4-sale-exam    | get-well-prepared-    | certkiller-sale-exam    | buy-discount-dumps    | how-to-get-prepared-for-the    | in-an-easy-way    | brain-dumps-sale    | with-pass-exam-guarantee    | accurate-study-material    | at-first-try    | 100%-successful-rate    | get-certification-easily    | material-provider-exam    | real-exam-practice    | with-pass-score-guarantee    | certification-material-provider    | for-certification-professionals    | get-your-certification-successfully    | 100%-Pass-Rate    | in-pdf-file    | practice-exam-for    | it-study-guides    | study-material-sku    | study-guide-pdf    | prep-guide-demo    | certification-material-id    | actual-tests-demo    | brain-demos-test    | best-pdf-download    | our-certification-material    | best-practice-test    | leading-provider-on    | this-course-is-about    | the-most-reliable    | high-pass-rate-of    | high-pass-rate-demo    | recenty-updated-key    | only-for-students-free-download    | courseware-plus-kit-for    | accurate-answers-of    | the-most-reliable-id    | provide-training-for    | welcome-to-buy    | material-for-success-pass    | provide-free-support    | best-book-for-pass    | accuracy-of-the-answers    | pass-guarantee-id    | pass-exam-key    | pass-sku-id    | study-for-exid    | pdf-sku-exid    | sku-pdf-id    | pdf-demo-key    | exam-demo-ske    | pass-it-dump    |
http://www.menuiserie-dauvergne.com/    | http://www.menuiserie-dauvergne.com/    |