We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Way to move the mouse pointer from inside program
Page Index Toggle Pages: 1
Way to move the mouse pointer from inside program? (Read 603 times)
Way to move the mouse pointer from inside program?
Nov 26th, 2008, 10:44pm
 
Say for example I'd like to make the mouse pointer chase a ball rather than the ball following the mouse.  How would I go about changing the pointer's positioning?  I've tried modifying the mouseX and mouseY variables but that does not move the pointer.
Re: Way to move the mouse pointer from inside prog
Reply #1 - Nov 27th, 2008, 12:32am
 
Re: Way to move the mouse pointer from inside prog
Reply #2 - Nov 27th, 2008, 12:52am
 
Ok, I tried that and I can indeed move the mouse with the robot class.  However, it moves it relative to the screen coordinates.  How do I move it relative to the processing windows coordinates?  Or alternatively, how do I get the mouse's current position relative to the screen coordinates that the robot class uses?
Re: Way to move the mouse pointer from inside prog
Reply #3 - Nov 27th, 2008, 2:02am
 
You can get the sketch's coordinates on screen with frame.getLocationOnScreen().

It needs to be adjusted for window decorations (borders, title...).
Re: Way to move the mouse pointer from inside prog
Reply #4 - Nov 27th, 2008, 4:24am
 
You can also check out http://processing.org/hacks/hacks:robot
Re: Way to move the mouse pointer from inside prog
Reply #5 - Nov 28th, 2008, 2:40am
 
ok, I've got everything to work except how to I account for the window decorations?  I need this to work across platforms as well.  All I need to do is move the mouse relative to it's current position.  Isn't there an easier way?
Re: Way to move the mouse pointer from inside prog
Reply #6 - Nov 28th, 2008, 8:27am
 
frame.isDecorated()

google Java Frame
and Java Robot

-seltar
Re: Way to move the mouse pointer from inside prog
Reply #7 - Nov 28th, 2008, 11:13am
 
jsavage wrote on Nov 28th, 2008, 2:40am:
All I need to do is move the mouse relative to it's current position.

Untested (even less in Processing's context) but it might be useful: Determine Absolute Cursor Coordinates.
Page Index Toggle Pages: 1