We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I wrote a code that selects a color from the camera input and tracks this color. I want to use this as a remote to control my computer with a little colored object (works fine with a pen). Now I would like to run the sketch in background and control the mouse with my pen. I have absolutely no idea how to do that, any suggestions ?
Answers
Would the Robot class be what you're looking for?
Be careful with the sketch below, though. If you accidentally click on another window, depending on what you know about your operating system, you may or may not be able to close the sketch window, anymore.
Otherwise, I'm sure you can figure out what code performs what action.
That's perfect, thank you !
Could you also use something like this to click on the external program, like my computer for example? Can I use this code and what should I add to it that can aid in that?
@TechWiz777 With the Robot class, you can do essentially anything involving the keyboard and mouse, in any order. You can even shut your own computer down, if you can to do it accurately.
Anything listed in the "Method Summary" section of the following link can be used to help you with mouse/keyboard input needs: http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html
If you need further help, feel free to PM me, or make a new post. Let's not litter the OP's notification box with comments from an outside conversation. ;)
@MenteCode thank you!
@MenteCode is there a way that we can have this sketch you provided click on a specific point in the screen ? using just x&y coordinates ? thats be so much easy for me since im wayyyy to new to the whole trig functions/parameters "cos,sin...ect"
Sure, this is what I do:
@Jai:
Exactly what @AverageJoe said.
Don't worry about the sin and cos functions. They're there just so the cursor would move in a circle, as a demonstration of what you can do with the Robot class. :)