PDA

Click to See Complete Forum and Search --> : Taskbar Programs


Shark
Oct 11th, 2000, 04:58 PM
How do I get all the programs that appears on the taskbar?

Oct 11th, 2000, 05:15 PM
Use EnumWindows which will retrieve ALL open windows.

Cdoe for a Module

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer

iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1

If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
Debug.Print Left(sName, Length - 1)
End If

EnumWindowsProc = 1
End Function


Code for a CommandButton

EnumWindows AddressOf EnumWindowsProc, 0

gwdash
Oct 14th, 2000, 07:41 PM
This is Megatron's code with a modification to include the IsWindowVisible API, to check if the window is visible(enumwindows returns some non-visible ones)


Cdoe for a Module

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As Long) As Long
' New Declare


Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer
If IsWindowVisible(hwnd) ' Added
iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1

If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
Debug.Print Left(sName, Length - 1)
End If
End If ' Added
EnumWindowsProc = 1
End Function


Code for a CommandButton

EnumWindows AddressOf EnumWindowsProc, 0

bonjour
Oct 23rd, 2000, 10:30 PM
i got this to work, but am wondering how do you get the information in a text box. Example: I build a form with a text box and want a listing of all open apps displayed in the text box.

Oct 23rd, 2000, 10:49 PM
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer

iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1

If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
'Debug.Print Left(sName, Length - 1)
Form1.Text1.text = Left(sName, Length - 1)
End If

EnumWindowsProc = 1
End Function