Results 1 to 4 of 4

Thread: How to get a list of all windows

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Location
    NH
    Posts
    90

    How to get a list of all windows

    I am trying to get the name of a particular window but the title can change at the end like
    CNI EDITORIAL - Daily vs CNI EDITORIAL - SUNDAY
    So I was trying to get a list of all the windows so that I could compare the first part of the string??

    THank Scott

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Use the class name instead of window title.
    Please rate my post.

  3. #3
    Addicted Member
    Join Date
    Sep 2002
    Location
    Middle Earth
    Posts
    156
    or... EnumWindows () in user32.dll.

  4. #4
    Hyperactive Member phrozeman's Avatar
    Join Date
    Apr 2000
    Location
    Netherlands
    Posts
    442
    VB Code:
    1. Private Sub Form_Load()
    2.        EnumWindows AddressOf EnumWindowsProc, ByVal 0&
    3. End Sub
    4.  
    5. 'module code
    6. Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
    7. Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    8. Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    9.  
    10. Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
    11.     Dim sSave As String, Ret As Long
    12.     Ret = GetWindowTextLength(hwnd)
    13.     sSave = Space(Ret)
    14.     GetWindowText hwnd, sSave, Ret + 1
    15.     If Not sSave = "" Then Form1.List1.AddItem sSave
    16.         EnumWindowsProc = True
    17. End Function
    There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me

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