B4J Question Reading mouse position warning

ThRuST

Well-Known Member
Licensed User
Longtime User
I am adding full screen detection to read the current mouse cursor position by using a timer which works but displays a warning message in the logs. Any assistance for a workaround is appreciated, thanks.

Process globals
B4X:
    Dim MousePositionTimer As Timer
    Dim temp,robot As JavaObject
    Dim x,y As Int
    Dim Lbl_PanelTopPosition As Label

Appstart
B4X:
MousePositionTimer.Initialize("MousePositionTimer", 1)
    robot = temp.InitializeStatic("com.sun.glass.ui.Application").RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
    MousePositionTimer.Enabled = True

B4X:
Sub MousePositionTimer_tick

        x = robot.RunMethod("getMouseX",Null) ' x position
        y = robot.RunMethod("getMouseY",Null) ' y position
        Lbl_PanelTopPosition.Text = x & " " & y
    
End Sub

Log:

I use Java jdk/rne v9.0.1.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Thanks, that's good to know so we can all can still use this method. I'ld like to add that optional alternatives might be to use the jAWTRobot or the jNativeHook library which also is useful to track mouse events.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Correction: I am not sure about if Nativehook supports MouseMove event even though it supports Mouseclicks and Keypress events.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@Erel Thanks, I decided in this case to go for a combo with your of course very useful solution and also Roycefers great libraries. That's why I mentioned them
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…