Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getwindow() returns more window names than expected

Status
Not open for further replies.

1chicken

Programmer
Jun 11, 2003
20
0
0
US
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
 
Considering you're talking about VBA code here, this question needs to be posted in forum707.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top