B4J Question CTRL+V with message - Method: keyPress not matched

Discussion in 'B4J Questions' started by petr4ppc, May 28, 2019.

  1. petr4ppc

    petr4ppc Active Member Licensed User

    Dear friends,

    please for advice, I am using ctrl + v for paste:
    Code:
    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:

    Please, what can I do with this? It was functioned in older version of Java
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What is the purpose of this code? You should remove it.

    Code:
    If fx.Clipboard.HasString Then
           ta.Text = fx.Clipboard.GetString
     
    End If
     
  3. petr4ppc

    petr4ppc Active Member Licensed User

    Thank you very much for answer,

    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:

    Code:
    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:

    Best regards
    p4ppc
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    No need to write Array As Object. It is enough to write Array.

    How is robot initialized?
     
  5. petr4ppc

    petr4ppc Active Member Licensed User

    Thank you for your answer Erel,

    Robot init:
    Code:
    robot = temp.InitializeStatic("com.sun.glass.ui.Application").RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
    I am using this:
    Code:
    #VirtualMachineArgs: --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
    Now I am using this code (without "object"):
    Code:
    robot.RunMethod("keyPress"Array (17))
        robot.RunMethod(
    "keyPress"Array (86))
        robot.RunMethod(
    "keyRelease"Array (17))
        robot.RunMethod(
    "keyRelease"Array (86))
    and I still get:
    Best regards,
    p4ppc
     
  6. Daestrum

    Daestrum Well-Known Member Licensed User

    Erel likes this.
  7. Erel

    Erel Administrator Staff Member Licensed User

    Example:
    Code:
    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")))
    Keycodes: https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/input/KeyCode.html
     
    petr4ppc likes this.
  8. petr4ppc

    petr4ppc Active Member Licensed User

    Thank you very much dear B4X friends,

    Erel - it is 100% perfect, thank you very much and best regards :)
    p4ppc
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice