Results 1 to 5 of 5

Thread: Taskbar Programs

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    How do I get all the programs that appears on the taskbar?
    Mako Shark
    Great White

  2. #2
    Guest
    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

  3. #3
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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]

  4. #4
    Member
    Join Date
    Jul 2000
    Posts
    37

    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.

  5. #5
    Guest
    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
  •  



Click Here to Expand Forum to Full Width