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.05
  • 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
      • 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
 

Attachments

  • SD_NativeAccess 1.05.zip
    8.4 KB · Views: 17
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
example
 

Attachments

  • Sample_NativeAccess.zip
    2.2 KB · Views: 118

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