B4J Question AWRobot movemouse moves to a random position

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.

B4X:
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(500, 500)

    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:

stevel05

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

It appears to be working correctly here.
 

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.
 

jroriz

Active 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.
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
 
Top