Dim ta As TextArea
ta.Initialize("ta")
Dim jo As JavaObject = ta
jo.RunMethod("paste", Null)
ta.SelectAll
robot.RunMethod("keyPress", Array As Object(17))
robot.RunMethod("keyPress", Array As Object(86))
robot.RunMethod("keyRelease", Array As Object(17))
robot.RunMethod("keyRelease", Array As Object(86))
and I got this message:
java.lang.RuntimeException: Method: keyPress not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
at XX.uz.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv2(main.java:15512)
at XX.uz.main._boarrived(main.java:19708)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA$3.run(BA.java:247)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
the purpose is, that I want place the string programaticaly with function CTRL+V to cursor position (for example if I have opened notepad)
I have string in clipboard - this is OK,
but I am doing some mistake with:
B4X:
robot.RunMethod("keyPress", Array As Object(17))
robot.RunMethod("keyPress", Array As Object(86))
robot.RunMethod("keyRelease", Array As Object(17))
robot.RunMethod("keyRelease", Array As Object(86))
I get:
java.lang.RuntimeException: Method: keyPress not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
at XX.uz.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv2(main.java:15512)
at XX.uz.main._boarrived(main.java:19708)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA$3.run(BA.java:247)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.RuntimeException: Method: keyPress not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
at XX.uz.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv2(main.java:15512)
at XX.uz.main._boarrived(main.java:19708)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA$3.run(BA.java:247)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Dim robot As JavaObject
robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
Dim KeyCode As JavaObject
KeyCode.InitializeStatic("javafx.scene.input.KeyCode")
robot.RunMethod("keyPress", Array(KeyCode.GetField("A")))
robot.RunMethod("keyRelease", Array(KeyCode.GetField("A")))
Dim robot As JavaObject
robot.InitializeNewInstance("javafx.scene.robot.Robot", Null)
Dim KeyCode As JavaObject
KeyCode.InitializeStatic("javafx.scene.input.KeyCode")
robot.RunMethod("keyPress", Array(KeyCode.GetField("A")))
robot.RunMethod("keyRelease", Array(KeyCode.GetField("A")))
robot.RunMethod("keyPress", Array(KeyCode.GetField("LEFT_PARENTHESIS")))
robot.RunMethod("keyRelease", Array(KeyCode.GetField("LEFT_PARENTHESIS"))
....
and more
instead of constants how can I directly use the value of the key pressed?
Thanks
Edit:
Sorry, I forgot to use the shift key
but the question always remains valid