Mouse Automation in Java. Build your own GUI tool to record mouse actions and play them later.
This is a tutorial on how you can automate your mouse through Java. I have also created a small tool where you can save mouse inputs with arguments. After, you're done with feeding the inputs, click execute and the tool will execute all the inputs you have saved. This is a very useful tool if you want to automate a specific task. A checkbox allows you to repeat the execution infinite number of times.
Here's a snippet of the code:
Robot bot = null;
try {
bot = new Robot();
bot.mouseMove(parameter, parameter2);
int mask = InputEvent.BUTTON1_DOWN_MASK; //For Mouse Button1 Click
bot.mousePress(mask); //Press Button
bot.mouseRelease(mask); //Release Button
} catch (Exception failed) {
System.err.println("Failed instantiating Robot: " + failed);
}
You can download the Java Executable if you want to run the program on your system from this link.
How to Execute:
1) Click on this link and download.
2) Open Terminal (CMD, if you're on windows).
3) Type cd /path/to/file
4) java -jar ./EmulateMouse.jar (Make Sure you have java installed.)
How to use:
You have four options:
1) Move Mouse - This accepts two arguments. Enter the X and Y coordinates where you want your mouse to be moved.
2) Click - Emulates a mouse click.
3) Right Click - Emualtes a Right Click
4) Delay - Wait for x seconds.
Select the required option, enter correct arguments and click on Add Task.
Once you're done with adding tasks, click on Execute button. You can also check "Repeat" checkbox if you want these to be repeated. Please use Repeat very carefully. You might get stuck because your mouse will move automatically. (In such a case, you can go to your cmd where the EmulateMouse.jar process is running and press Ctrl+C to terminate the process)
You can find the GUI Tool and its source code at my GitHub Repo: https://github.com/SiddhantMinocha/EmulateMouse
The code is very easy and self explanatory. Hence, no need for long theories. ;)
Lots of Love! :)
Here's a snippet of the code:
Robot bot = null;
try {
bot = new Robot();
bot.mouseMove(parameter, parameter2);
int mask = InputEvent.BUTTON1_DOWN_MASK; //For Mouse Button1 Click
bot.mousePress(mask); //Press Button
bot.mouseRelease(mask); //Release Button
} catch (Exception failed) {
System.err.println("Failed instantiating Robot: " + failed);
}
You can download the Java Executable if you want to run the program on your system from this link.
How to Execute:
1) Click on this link and download.
2) Open Terminal (CMD, if you're on windows).
3) Type cd /path/to/file
4) java -jar ./EmulateMouse.jar (Make Sure you have java installed.)
How to use:
You have four options:
1) Move Mouse - This accepts two arguments. Enter the X and Y coordinates where you want your mouse to be moved.
2) Click - Emulates a mouse click.
3) Right Click - Emualtes a Right Click
4) Delay - Wait for x seconds.
Select the required option, enter correct arguments and click on Add Task.
Once you're done with adding tasks, click on Execute button. You can also check "Repeat" checkbox if you want these to be repeated. Please use Repeat very carefully. You might get stuck because your mouse will move automatically. (In such a case, you can go to your cmd where the EmulateMouse.jar process is running and press Ctrl+C to terminate the process)
You can find the GUI Tool and its source code at my GitHub Repo: https://github.com/SiddhantMinocha/EmulateMouse
The code is very easy and self explanatory. Hence, no need for long theories. ;)
Lots of Love! :)
0 comments:
Post a Comment