#AdditionalJar: jna-4.5.0
#AdditionalJar: jna-platform-4.5.0
Sub Process_Globals
Private titles As List
Private user32 As JavaObject
End Sub
Sub GetAllWindowsTitles As List
titles.Initialize
user32 = user32.InitializeStatic("com.sun.jna.platform.win32.User32").GetField("INSTANCE")
Dim callback As Object = user32.CreateEvent("com.sun.jna.platform.win32.WinUser.WNDENUMPROC", "callback", "")
user32.RunMethod("EnumWindows", Array(callback, Null))
Return titles
End Sub
Sub Callback_Event (MethodName As String, Args() As Object) As Object
If MethodName = "hashCode" Then Return 0
If MethodName = "toString" Then Return ""
If MethodName = "equals" Then Return False
If MethodName = "callback" Then
Dim title(512) As Char
user32.RunMethod("GetWindowText", Array(Args(0), title, 512))
Dim native As JavaObject
Dim text As String = native.InitializeStatic("com.sun.jna.Native").RunMethod("toString", Array(title))
text = text.Trim
If text.Length > 0 Then titles.Add(text)
End If
Return True
End Sub