How to create Android app that controls mouse position of computer?

Hi. I have developed similar type of application. Let me tell you how to create such type of application that controls mouse of your computer.

For this you need 2 application, one is desktop application (Java Code ) and other one is Android Application.

Android Side :

I have created one android application in which i have added 2 listeners onTouch and onRelease. What these 2 will do is that when we touch on our screen it find our position on the screen and when we move our hand on the screen and release our hand at that time also onRelease listener find our position on the screen. Now we have 2 positions, suppose first position is 4,2 and second position is 8,8. Means We have moved 4 in horizontal and 6 in vertical. I just send these 2 parameters using Restful webservices created on Java and deployed on my computer. This webservice gets called as soon as i release my hand from the screen.

Server Side (Computer):

I have created a service in Java that accepts 2 parameters one is horizontal and other one is vertical distance. In java we have Robot class that has method to move our mouse as per our requirement. So i called that method to move mouse with the parameters i just received in webservice request. You may have to multiple the parameters with 3 or 4 because as per our screen size of mobile, it shows very less movement on our system so to move 3 times of our system, just multiple the parameter with 3 before passing in the webservice.

*Apart from this you can also add functionality for right click and left click by adding onClick listener on android side, and on click call java webservice and from java webservice method you can call robot class to perform right or left click.

*I was using onTouch and onRelease listeners. So my computer mouse moves after i release my hand from screen. You can use other listeners of android that give you value even when you are moving your hand.

I hope this will help you. If you need any more help regarding any class, method or implementation, feel free to let me know.

Be the first to comment

Leave a Reply

Your email address will not be published.