سؤال

Is there anyway to do a mousemove event with java.awt.Component.dispatchEvent(AWTEvent)?

.dispatchEvent(new MouseEvent(client.a
                           .getComponentAt(1, 1),
                               MouseEvent.MOUSE_MOVED,
                               System.currentTimeMillis(),
                               MouseEvent.NOBUTTON,
                               x,y,
                               1,
                               false));

I got this now but it doesnt perform a mouse move. How can i do it?

Edit: I tried it like this but its not working:

.dispatchEvent(new MouseEvent(client.a
                           .getComponentAt(1, 1),
                               MouseEvent.MOUSE_MOVED,
                               System.currentTimeMillis(),
                               MouseEvent.NOBUTTON,
                               x,y,
                               0,
                               false));

Thanks, Jeffrey

هل كانت مفيدة؟

المحلول

I know of no way to do this the way you're trying as the MouseEvent (as far as I understand it) is for sending mouse messages to components not the operating system. Usually I've used the Robot class or JNA to actually move the mouse cursor on the screen.

نصائح أخرى

I use Abbot to emulate MouseEvent in my application. It was recently updated by an Oracle employee for Java 6, JUnit 4, etc.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top