B4J Question Mouse cursor Move - mouseMove

petr4ppc

Active Member
Licensed User
Dear friend, please for advice, what I am doing wrong?

I want move MouseCursor to X and Y

B4X:
Dim robot As JavaObject
                    robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
                    Dim Point2D As JavaObject
                    Point2D.InitializeStatic("javafx.scene.input.mouseMove")
                    robot.RunMethod("mouseMove", Array As Object(x, y))
I get in log:
java.lang.RuntimeException: Method: mouseMove not matched.
Thank you very much
best regards
p4ppc
 

petr4ppc

Active Member
Licensed User
Agraham, thank you for your answer

In older Java I have define x,y as:
B4X:
oldx = robot.RunMethod("getMouseX",Null)
oldy = robot.RunMethod("getMouseY",Null)
x=oldx+10
y=oldy+10
(this is bad fo Java 11, I know it now)

and I want add this function for Java 11:

B4X:
Dim robot As JavaObject
                    robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
                    Dim Point2D As JavaObject
                    Point2D.InitializeStatic("javafx.scene.input.mouseMove")
                    robot.RunMethod("mouseMove", Array As Object(x, y))
(this not functioned)

Thank you very much,
Best regards
p4ppc
 

agraham

Expert
Licensed User
I've just looked inside the JavaObject code and realized that the "not matched" error is not coming, as I thought, from Robot but is in fact being raised by JavaObject itself :( That explains my mistaken suggestion for your mousePress error earlier on!

The reason for the error is that the types being passed in the Array are not those required by the method. I guess that x and y are not declared as Doubles which is what mouseMove requires.
 
Top