B4J Library SD_NativeAccess (jna)

This library allows access to the jna to use some functions for managing windows and applications.
You need to get these JARs and include them in the additional libraries folder: jna-5.0.0 and jna-platform-5.0.0

With this library you can obtain the Handle of the applications that run on your Windows PC, both visible and invisible ones. A bit like you would with the task manager.
From the Hande you can get the name of the window, the coordinates and dimensions and finally the file name and path of the app.
There are many other functions that can be implemented with jna, as soon as I have time I will add a few more

SD_NativeAccess

Author:
Star-Dust
Version: 1.06
  • Na_Rectangle
    • Fields:
      • Height As Int
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Left As Int
      • Top As Int
      • Width As Int
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.
  • NativeAccess
    • Functions:
      • Class_Globals As String
      • FlashWindow(Handle As Object, Count As Int, DurateMillisec As Int, BlinkType As Int)
      • GetCOM As List
        USB or COM
      • GetIdleTime As Long
      • GetListWindowsHandle (OnlyVisible As Boolean) As List
      • GetListWindowsTitle (OnlyVisible As Boolean) As List
      • GetRegisterCurrentUser (KeyPath As String, KeyValue As String) As String
      • GetRegisterLocalMachine (KeyPath As String, KeyValue As String) As String
      • GetUSB As List
      • GetWindowRect (Handle As Object) As Na_Rectangle
      • GetWindowsActiveTitle As String
      • Initialize As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • KillWindowsByHandle (Handle As Object) As String
      • KillWindowsByName (Title As String) As String
      • Minimize (Handle As Object) As String
      • Monitor (On As Boolean) As String
      • SetForegroundWindow (Title As String) As String
      • SetWindowRec (Handle As Object, Left As Int, Top As Int, Width As Int, Height As Int) As String

Update
  • rel 1.01
    • Add Monitor (On As Boolean)
  • rel. 1.02
    • Added GetUSB
      returns the list of installed usb devices
    • Added GetCOM
      returns the list of serial port
    • Added GetIdleTime
      returns the user's idle time
  • rel 1.03
    • Added GetRegisterCurrentUser (KeyPath As String, KeyValue As String) As String
  • rel 1.04
    • Added GetRegisterLocalMachine (KeyPath As String, KeyValue As String) As String
  • rel 1.05
    • Added KillWindowsByName and KillWindowsByHandle
  • rel 1.06
    • Added FlashWindow
 

Attachments

  • SD_NativeAccess.zip
    8.9 KB · Views: 74
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
example
 

Attachments

  • Sample_NativeAccess.zip
    2.2 KB · Views: 265

Star-Dust

Expert
Licensed User
Longtime User
Update rel 1.01
  • Add Monitor (On As Boolean)
    Turn On or Off the monitor
B4X:
Na.Initialize
Na.Monitor(False)
Sleep(500)
Na.Monitor(True)
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update rel 1.02
  • Added GetUSB
    returns the list of installed usb devices
  • Added GetCOM
    returns the list of serial port
  • Added GetIdleTime
    returns the user's idle time
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 1.03
  • Addes GetRegisterCurrentUser (KeyPath As String, KeyValue As String) As String
Sample:
Log(Na.GetRegisterCurrentUser("SOFTWARE\Microsoft\Windows\CurrentVersion\Extensions","rtf"))
 

Cableguy

Expert
Licensed User
Longtime User
Hi @Star-Dust

Could you take a look at this and see if/how it could be implemented into or using your lib?
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
UPDATE rel 1.04
  • Added GetRegisterLocalMachine (KeyPath As String, KeyValue As String) As String
UPDATE Rel 1.05
  • Added KillWindowsByName and KillWindowsByHandle
 

Star-Dust

Expert
Licensed User
Longtime User
Unfortunately I don't have Windows 11 and can't try it :(
 

Cableguy

Expert
Licensed User
Longtime User
Unfortunately I don't have Windows 11 and can't try it :-(
I can be your test subject if you want... maybe creating a 31 function lib" just to try it out...
This would be very beneficial to all B4J users...
 

jmon

Well-Known Member
Licensed User
Longtime User
Hi, thank you for your work.
Would it be possible to add "flashwindow" (True / False)?
 

Star-Dust

Expert
Licensed User
Longtime User

Cableguy

Expert
Licensed User
Longtime User
Hi @Star-Dust

Could you take a look at this and see if/how it could be implemented into or using your lib?
Hi @Star-Dust,

Did you ever got to take a look at this one?
For those of us who like to use custom Title Bars, having to choose the native Tittle bar just to keep this functionality is hard, because it gives a bad user experience in some cases not to have it...
 

Star-Dust

Expert
Licensed User
Longtime User
Hi @Star-Dust,

Did you ever got to take a look at this one?
For those of us who like to use custom Title Bars, having to choose the native Tittle bar just to keep this functionality is hard, because it gives a bad user experience in some cases not to have it...
Dear friend,

You have already asked me this question privately and I replied that I don't use Windows 11, that jna 5 is not set up. To understand how it works it will take a lot of time to do tests in addition to Windows 11 and unfortunately there is no such time.
If they are small and quick things I will gladly add them.
 

Star-Dust

Expert
Licensed User
Longtime User
Is it possible to add a feature that disables Windows logo keys for full-screen and locked application scenarios?
I don't know this function, you can search for it in the jna documentation found in the first post.
 

byz

Active Member
Licensed User
Last edited:
Top