Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
public void GetMotion(){
            try {
            Robot  robot=new Robot();
            ServerSocket Server=new ServerSocket(2222);  
            System.out.println("Server Started..");
            
            float x = 0.0f;
            float y = 0.0f;
            int x1 = 0,y1 = 0;
            while (true) {   
                Point p=MouseInfo.getPointerInfo().getLocation();
                Socket Serversocket=Server.accept();
                System.out.println("Client Connected....");
                BufferedReader br=new BufferedReader(new InputStreamReader(Serversocket.getInputStream()));
                do {                    
                    String str=br.readLine();
                    if(str.startsWith("x:"))
                    {
                        x =Float.valueOf(str.substring(2));
                        x1=(int) x+p.x;
                        System.out.println("X:"+str.substring(2));
                    }
                    if(str.startsWith("y:")){
                        System.out.println("Y:"+str.substring(2));
                        y =Float.valueOf(str.substring(2));
                        y1=(int) y+p.y;
                    }
                    robot.mouseMove(x1,y1);
                     
                } while (true);
                
            } 
           
            
        } catch (AWTException ex) {
            System.out.println(ex);
        } catch (IOException ex) {
            Logger.getLogger(MouseMove.class.getName()).log(Level.SEVERE, null, ex);
        }
        }

This is the java code for controlling mouse using android on touch event. I am setting the pointer location from it.
But pointer is not moving on hole screen on computer it only moves size of android screen.
Posted
Updated 4-Oct-15 22:30pm
v2
Comments
vickeysanlge 5-Oct-15 5:48am    
please help...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900