Main Problem
I'm trying to create a widely applicable keypress simulation program, but I don't know how to use Java so I can only search for Q&As on the site, which is inefficient. So I want to open a new post and deal with these problems all in once:
I need the following functionality:
Press arbitrary keys (using key codes shown here) for example, some code like
press[65]
should press A.Press arbitrary mouse keys (including mouse down, mouse up and mouse click)
Move mouse to a specific location
rotate the scrolling of the mouse
Screen shot
How to do these small functionalities? Thanks!
Some work I've done
One can use these as a reference:
JLink
part:
Needs["JLink`"];
ReinstallJava[];
robotclass = JavaNew["java.awt.Robot"];
LoadJavaClass["java.awt.event.InputEvent"];
move[{x_, y_}] := robotclass@mouseMove[x, y];
mouseleftdown[] := robotclass@mousePress[InputEvent`BUTTON1UMASK];
mouseleftup[] := robotclass@mouseRelease[InputEvent`BUTTON1UMASK];
mouseleftclick[] := CompoundExpression[mouseleftdown[], mouseleftup[]];
mouseleftdoubleclick[] := Do[mouseleftclick[], 2];
Mathematica Part:
MousePosition[];
CurrentValue[{"MouseButtonTest",1}]