Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generating Mouseclick Programmatically  RSS feed

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from java.awt.Robot, are there any other ways to generate mouse click event programatically? Say, something like creating the event object manually and dispatch it to the event queue.

I haven't tried, but it seems that the java.awt.Robot require physical movement of the mouse and the window brought into the foreground and the coordinate of the target component known. I am looking for a way to automate the client without having the client window brought to the foreground. Something like letting the user to work on other things in the foreground without worrying about the automated task.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a button you can do button.doClick()
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a java.awt.Component.dispatchEvent() method. Is it related to generating event programmatically?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try it? Remember that the X and Y locations of mouse clicks are relative to the component on which you click, not the screen.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!