Dim robot As JavaObject
robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
Dim MouseButton As JavaObject
MouseButton.InitializeStatic("javafx.scene.input.MouseButton")
robot.RunMethod("mousePress", Array(MouseButton.GetField("PRIMARY"))) 'left button
robot.RunMethod("mouseRelease", Array(MouseButton.GetField("PRIMARY"))) 'left button
I get:
java.lang.RuntimeException: Method: mousePress not matched.
Just a wild guess but have you tried a Sleep(0) between press and release? It might be that it is only seeing the release as you are not returning to the main thread to process the press command. But there again it might not !
The MousePress and Mouserelease methods require a vararg argument which can be an array, but it has to be of the correct type:
B4X:
Dim robot As JavaObject
robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
Dim MouseButton As JavaObject
MouseButton.InitializeStatic("javafx.scene.input.MouseButton")
Dim MBA As Object = MouseButton.InitializeArray("javafx.scene.input.MouseButton",Array(MouseButton.GetField("PRIMARY")))
robot.RunMethod("mousePress", Array(MBA)) 'left button
robot.RunMethod("mouseRelease", Array(MBA)) 'left button
Dim robot As JavaObject
robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
Dim MouseButton As JavaObject
MouseButton.InitializeStatic("javafx.scene.input.MouseButton")
robot.RunMethod("mousePress", Array(MouseButton.GetField("PRIMARY"))) 'left button
Sleep(50)
robot.RunMethod("mouseRelease", Array(MouseButton.GetField("PRIMARY"))) 'left button
and I get same result in logs:
java.lang.RuntimeException: Method: mousePress not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)