How do I get the handle of all applications on the TaskBar?
Printable View
How do I get the handle of all applications on the TaskBar?
That is where the first post went. I posted and couldn't find it in the general. Thanks Megatron.
This can do it...
Code:Public Declare Function SeekWin Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As _
Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Sub GetAllWin (HwndList() As Long)
Dim c, hwdwin, cnt
Do Until SeekWin(vbNull, c, vbNull, vbNull) = 0
hwdwin = SeekWin(vbNull, c, vbNull, vbNull)
cnt = cnt + 1
ReDim HwndList(cnt) As Long
HwndList (cnt) = hwdwin
c = hwdwin
Loop
End Sub
But that retrieves all open windows. Do you know how to get ones only visible on the taskbar?
Hi Shark
You can use the IsWindowVisible API.
[Edited by Nitro on 10-11-2000 at 06:47 PM]Code:Option Explicit
Public Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Sub Main()
Call EnumWindows(AddressOf p_EnumWindowsProc, 0)
End Sub
Public Function p_EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim str_Data As String
Dim lng_Length As Long
If IsWindowVisible(hwnd) <> 0 Then
lng_Length = GetWindowTextLength(hwnd) + 1
If lng_Length > 1 Then
str_Data = Space(lng_Length)
Call GetWindowText(hwnd, str_Data, lng_Length)
Debug.Print Left(str_Data, lng_Length - 1)
End If
End If
p_EnumWindowsProc = 1
End Function
How can I use your example Escaflowne?