是否可以在Java中编写宏?

bar*_*red 2 java macros mouseclick-event

我希望在我的Java应用程序中发生某些事件时快速单击另一个应用程序.

鉴于我知道屏幕上我想要注册点击的坐标,我的Java应用程序是否可以告诉操作系统点击那里?

我可能想要注册多次点击.

我也可能/想要注册键盘笔划.这也可能吗?

jjn*_*guy 7

你应该看一下RobotJava 中的类.它将允许您模拟点击和鼠标移动.

您可能想要的方法特别是:

void    keyPress(int keycode) 
          Presses a given key.
void    keyRelease(int keycode) 
          Releases a given key.
void    mouseMove(int x, int y) 
          Moves mouse pointer to given screen coordinates.
void    mousePress(int buttons) 
          Presses one or more mouse buttons.
void    mouseRelease(int buttons) 
          Releases one or more mouse buttons.
Run Code Online (Sandbox Code Playgroud)