|
-
Oct 11th, 2000, 04:58 PM
#1
Thread Starter
Addicted Member
How do I get all the programs that appears on the taskbar?
-
Oct 11th, 2000, 05:15 PM
#2
Use EnumWindows which will retrieve ALL open windows.
Cdoe for a Module
Code:
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
Code:
EnumWindows AddressOf EnumWindowsProc, 0
-
Oct 14th, 2000, 07:41 PM
#3
Fanatic Member
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
Code:
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
Code:
EnumWindows AddressOf EnumWindowsProc, 0
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 23rd, 2000, 10:30 PM
#4
Member
how do ya get a list
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
#5
Code:
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|