B4J Question AWRobot movemouse moves to a random position

Discussion in 'B4J Questions' started by jroriz, Nov 11, 2018.

  1. jroriz

    jroriz Active Member Licensed User

    The code below produces random values, correcting from the fifth interaction.
    It works properly for Windows 7, but for Windows 10 it produces this strange behavior.

    Code:
    Sub AppStart (Form1 As Form, Args() As String)
        MainForm = Form1
        
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
        MainForm.Show

        
    For ix = 1 To 10
            Move 
        
    Next
    End Sub


    Sub Move()

        
    Dim temp, robot As JavaObject
        
    Dim c3po As AWTRobot
        robot = temp.InitializeStatic(
    "com.sun.glass.ui.Application").RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
      
        c3po.MoveMouse(
    500500)

        
    Dim MouseX, MouseY As Int
        MouseX = robot.RunMethod(
    "getMouseX",Null' screen co-ordinate not the forms
        MouseY = robot.RunMethod("getMouseY",Null' as x
      
        
    Log("X " & MouseX)
        
    Log("Y " & MouseY)
    End Sub
    Result:
    X 422
    Y 541
    X 519
    Y 491
    X 496
    Y 501
    X 500
    Y 501
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500

    Windows settings:

    windows1.PNG
     
    Last edited: Nov 11, 2018
  2. stevel05

    stevel05 Expert Licensed User

    Have you got the latest version of AWTRobot? (v1.55)

    It appears to be working correctly here.
     
  3. Roycefer

    Roycefer Well-Known Member Licensed User

    You are using a very old version of the jAWTRobot library. I recommend you use the latest version.

    However, that won't fix your problem. Your problem is most likely caused by Windows' mouse acceleration settings.
     
  4. jroriz

    jroriz Active Member Licensed User

    Hi. Thanks for the help.
    Updated the library, and set the mouse speed to max.
    Changed mousemove to c3po.RobotMouseMoveTo(500,500).

    Still not working...
    Any other help?

    New results:
    Waiting for debugger to connect...
    Program started.
    X 469
    Y 603
    X 507
    Y 475
    X 499
    Y 505
    X 499
    Y 500
    X 501
    Y 500
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500
    X 500
    Y 500
     
  5. Roycefer

    Roycefer Well-Known Member Licensed User

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