B4J Question Mouse move and Click - in IDE=OK, after compiling (Java 11)=NOK

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends,

please, where can I do mistake?
In IDE I can set cursor position and I can do Click action...everything is OK
but
if I compile code (Java 11) and if I run standalone file on same or other computer - it is not functioned...

It is some advice where I must find mistake?
Thank you
p4ppc
 

agraham

Expert
Licensed User
Longtime User
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear Agraham,

I have returned home and I continue on project. Thank you for your answer.
1. In UI of B4J version 7.51 I am working with this code:

B4X:
' ***********  this code for move Cursor
                              Dim x as Double = 50
                              Dim y as Double = 50
                              Private robot As JavaObject
                              Dim jo As JavaObject
                              jo.InitializeStatic("com.sun.glass.ui.Application")
                              robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
                              robot.RunMethod("mouseMove", Array As Object( x, y))

' *********** and this code for click                             
                              Dim robot As JavaObject
                              robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
                              Dim MouseButton As JavaObject
                              MouseButton.InitializeStatic("javafx.scene.input.MouseButton")
                              Dim MPA As Object = MouseButton.InitializeArray("javafx.scene.input.MouseButton",Array(MouseButton.GetField("PRIMARY")))
                              robot.RunMethod("mousePress", Array(MPA)) 'left button
                              robot.RunMethod("mouseRelease", Array(MPA)) 'left button

if I am working with UI and if I am running program via UI, everything is OK, the code is working well.

but

if I compile this code then I close UI(b4j) and then I run only compiled JAR file( final jar file I get from B4JPackager) , then the code which use cursor functions I described is not working.

Why the code is functioned only when I am running the code in UI? Why code is not functioned if I run JAR file?
Thank you
p4ppc
 
Last edited:
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Agraham...
nothing happen...

Cursor is not set to position and click is not realised. Nothing happen.
Value x and y I have declared as Double.

Thank you
p4ppc
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
My guess is you are missing a module. You should put some code in to check what is happening. You could write the information to a Label or another text view and see that the events are happening and that the JavaObjects contain what you expect them to contain. I haven't donea lot with B4J but I think there may be a way to open a console window and log results to that.
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Please what does it mean: My guess is you are missing a module. ?
It does it mean that some module is lost when UI is compiling my code? Because everything is OK when I am running code in B4J UI.

When I am testing what is happening via running the code with run_debug file - here I see no errors in Logs, but the function of cursor positioning and clicking is not functioned

Thank you
p4ppc
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Thank you very much for your answer Erel,

1 - I have 8.5 (Thank you for great work)
2 - done
3 - done
4 - done
5 - done

I can write for certain, that program stop here (app not crash, only Mouse cursor functions are not working):
B4X:
Log("1")
Robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
Log("2")

I see in Logs "1"
I not see in Logs "2"

Thank you
p4ppc
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
I found it, soultion is:
B4X:
robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)

Best regards
p4ppc
 
Upvote 0
Top