B4J Question Java10/11 - Raspberry and Method createrobot for send keypress

micro

Well-Known Member
Licensed User
Hi to all
report here a problem already brought in the following thread
https://www.b4x.com/android/forum/threads/liberica-javafx-limitation.97261/
for my needs I don't use the javafx virtual keyboard but my custom keyboards.
For simulate the pressure of a keyboard key i use this line code
B4X:
Dim robot As JavaObject
Dim jo As JavaObject
jo.InitializeStatic("com.sun.glass.ui.Application")
robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null) '<--Fails
robot.RunMethod("keyPress", Array As Object(13))
Sleep(50)
robot.RunMethod("keyRelease", Array As Object(13))
No problem with java 8_151 and openjfx-8u60

Of course also with the JAWTRobot library fails
is there another way to get the simulation of a keypress?
Thanks
 

micro

Well-Known Member
Licensed User
Are you trying to send the keystroke to a text field?
Yes
but the application crash before to Run Method "keypress", as already explained above is this line code the problem
B4X:
robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null) '<--Fails
that's because I asked for another solution
Thanks
 

micro

Well-Known Member
Licensed User
What are you trying to do? You can change the text field text directly
Ok, this is simply
I see what is the last object that has taken focus and if it is a TextField I write the character directly
but the problem is with Enter, Back, Tab etc.
Example:
Txt.Text = Txt.Text & Chr(13) or CRLF
If i want to simulate the Enter key, not active the Event 'Action'
With Back the solution could be found, but for others types of keys or special keys it is a bit difficult if not impossible.
Thanks
 
Top