Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

generate mouse events  RSS feed

 
juan manuel Fernandez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this is my first post here, hope to be clear enough so someone can help me.
After a couple of hours digging i cant find a way to make a java program to generate mouse events. I found the Robot class that has the method mousemove(x,y) but I dont need the pointer to be relocated at some position in the screen.
What i need is to translate some input (from jinput, already reading a book on that) to "real" mouse movements.
for example:
if you press key 1: the mouse should go 1 unit forward.
if you press key 2: the mouse should go 2 units forward.
and so on..

the Robot.mousemove(x,y) will magically make the pointer appear at x y in the screen. besides if I see that the pointer is at (10, 10) an I relocate it at (10,9) and repeat it several times the screen will end at (10,0)...

I would like to enable an other program that is expecting mouse movements to believe that the mouse moved forward, backward, etc... like if someone actually moved the mouse. NOTHING TO DO WITH the screen!

Hope someone knows how to do this.
cheers!
[ December 09, 2008: Message edited by: juan manuel Fernandez ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds like you just want to fire off a MouseEvent

this is one of the constructors


google
"new MouseEvent"
(include the quotes) and you should find sample code
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just another cross poster.
http://forums.sun.com/thread.jspa?threadID=5354012
 
juan manuel Fernandez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Michael Dunn! I found somthing I`ll read it tonight
and, Darryl Burke, thats right, I posted the same question in:
Linuxquestions.org
http://forums.sun.com/
here, and at some guy`s blog
because I didnt think that asking in only one place would be the best thing to do...
bye.
 
Rob Spoor
Sheriff
Posts: 21089
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by juan manuel Fernandez:
because I didnt think that asking in only one place would be the best thing to do...
bye.

It isn't, but please Be Forthright When Cross Posting To Other Sites.
It can be frustrating posting an elaborate answer only to later find out that someone has posted the same answer previously on another forum.
 
juan manuel Fernandez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ups! it comes clear that I spent more time asking than answering..
It is frustrating to answer an elaborated question and not receiving an answer too..
sorry, I didn't think from this perspective and you are absolutely right..
wont happen again.
---
that said..
HERE I found something interesting. Thanks

http://www.itapizaco.edu.mx/paginas/JavaTut/froufe/parte11/cap11-13.html
[ December 10, 2008: Message edited by: juan manuel Fernandez ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!