B4J Question Get Current Mouse Pointer Type (inline JAVA)

Magma

Expert
Licensed User
Longtime User

agraham

Expert
Licensed User
Longtime User
B4J UI is implemented with JavaFX not AWT so you can't. You could try the code below. If you don't explicitly set the cursor to a JavaFX one it appears to return Null. I'm not very well acquainted with JavaFX but it seems to work.
B4X:
Sub Button1_Click
    Dim formm, scene, cursor As JavaObject
    formm = MainForm
    scene = formm.GetField("scene")   
    Log(scene.RunMethod("getCursor", Null))
    cursor.InitializeStatic("javafx.scene.Cursor")
    scene.RunMethod("setCursor", Array(cursor.GetField("CLOSED_HAND")))
    Log(scene.RunMethod("getCursor", Null))
End Sub
Cursor types are here
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
B4J UI is implemented with JavaFX not AWT so you can't. You could try the code below. If you don't explicitly set the cursor to a JavaFX one it appears to return Null. I'm not very well acquainted with JavaFX but it seems to work.
B4X:
Sub Button1_Click
    Dim formm, scene, cursor As JavaObject
    formm = MainForm
    scene = formm.GetField("scene")  
    Log(scene.RunMethod("getCursor", Null))
    cursor.InitializeStatic("javafx.scene.Cursor")
    scene.RunMethod("setCursor", Array(cursor.GetField("CLOSED_HAND")))
    Log(scene.RunMethod("getCursor", Null))
End Sub
Cursor types are here


If it is not a b4j window active... if it is desktop of windows... or different app ?

how can we get it ?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Why do you need to? You would need to poke around inside Windows itself to do such things.
Well I need it for an app: remote administration... .when capturing screen not getting mousepointer... so need to know type of mousepointer i have in remote... to set it at my client window...

thought that in #IFJAVA... java.awt.Cursor.getType() will do the job... because already used other java.awt.* and worked...

....hmmm...
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
I'm a bit rusty on the Windows API and have never used JNA Win32 but in Windows each input thread has a cursor and each window has an input thread to handle the message loop so each window has its own cursor - the desktop itself is a window. To get the cursor you would need to get the window handle of the window of interest and take it from there but I can't tell you how to do that with JNA.
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
@agraham I understand...

I am posting here not only to answered by you (Thanks again) - hope, others see and if already know help me....

Found some code after a lot of searching - that may be help to extract the GetCursor needed (i just wanna know the type... of mousecursor of any windows is front or desktop) - So may be need to use HWND, may be others... my java knowledge is too little for that...

 
Upvote 0
Top