I am using the Robot class to move the mouse. My mouse has 10 buttons, and I would like to simluate the 10th button being clicked, then dragged. Is it possible to use the buttons beyond the first 3?
Printable View
I am using the Robot class to move the mouse. My mouse has 10 buttons, and I would like to simluate the 10th button being clicked, then dragged. Is it possible to use the buttons beyond the first 3?
I am only familiar ways to get the Robot class to click the first through third mouse buttons, but not any more. My guess is that you'll have to step outside of Java for this such as by using JNI, JNA or linking your Java program with an OS-knowledgeable program such as AutoIt. Question: does your mouse come with its own drivers and programmable buttons? Did it come with any Jar files?
I am on linux (default drivers), but I will see if there are any jars. Thanks.
Since very few people have a 10-button mouse, I'm guessing that portability isn't a concern. You could write a small program with a MouseListener#mousePressed(...) that echoes the int value of MouseEvents#getButton() to the console or a GUI element such as a JLabel (or even add each value to a JList) and observe the value generated when button 10 is pressed. Then use that value in your code.
Be aware that any change (using a different mouse, updating the mouse driver software ...) may cause your program to break.
Also note that automated play is banned in most online games.
db
Thanks for the reply. At this point, I have no concern about portability. This is not for any online game :)
I am working on my own vision based gesture system, and in an attempt to avoid re-inventing the wheel, I am using another program, Easystroke. This progam, when mouse button 10 is clicked and dragged, draws on the screen. When finished, It matches to some pre-configured gestures, and performs the action. I am simply trying to transfer control from the mouse to hand via image processing.
I tried the thing with the mouse event, and Buttons 1-3 returned the button number, e.g. Left click = 1. Every other "extra" button simply returns 0. However, robot takes InputEvent.BUTTON1_MASK, which returns 16. Mouse event is giving the button number, and InputEvent is some other ID.