Hi. I am trying to read the desktop window names and put them in a list. The problem is that I get a bunch of junk - IME, Tooltip, etc. I just want the windows on the taskbar that the users are going to use. The code works really well but I'd like to know if there's a way to get just active windows that are on the taskbar.
Here is my code (vba):
Sub LoadTaskList()
Dim Currwnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long
Dim i As Integer
Dim hwnd As Long
Dim hwndStart As Long
Dim sClass As String
For i = List1.ListCount - 1 To 0 Step -1
Me.List1.RemoveItem i
Next
hwndStart = GetDesktopWindow()
Currwnd = GetWindow(hwndStart, GW_CHILD)
While Currwnd <> 0
'Parent = GetParent(hwndStart)
Length = GetWindowTextLength(Currwnd)
TaskName = Space$(Length + 1)
Length = GetWindowText(Currwnd, TaskName, Length + 1)
TaskName = Left$(TaskName, Len(TaskName) - 1)
If Length > 0 Then
If TaskName <> Me.Caption Then
Me.List1.AddItem TaskName
End If
End If
Currwnd = GetWindow(Currwnd, GW_HWNDNEXT)
DoEvents
Wend
End Sub
Here is my code (vba):
Sub LoadTaskList()
Dim Currwnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long
Dim i As Integer
Dim hwnd As Long
Dim hwndStart As Long
Dim sClass As String
For i = List1.ListCount - 1 To 0 Step -1
Me.List1.RemoveItem i
Next
hwndStart = GetDesktopWindow()
Currwnd = GetWindow(hwndStart, GW_CHILD)
While Currwnd <> 0
'Parent = GetParent(hwndStart)
Length = GetWindowTextLength(Currwnd)
TaskName = Space$(Length + 1)
Length = GetWindowText(Currwnd, TaskName, Length + 1)
TaskName = Left$(TaskName, Len(TaskName) - 1)
If Length > 0 Then
If TaskName <> Me.Caption Then
Me.List1.AddItem TaskName
End If
End If
Currwnd = GetWindow(Currwnd, GW_HWNDNEXT)
DoEvents
Wend
End Sub