Results 1 to 4 of 4

Thread: How do I capture every Window ??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    87

    Post

    I want to capture every window and create a picturebox for each window in the size of each window, and I want to know the caption of each window.....and when I move the picturebox, I want the window with that caption to move..

  2. #2
    New Member
    Join Date
    Aug 1999
    Posts
    8

    Post

    Sounds like you want to joke around huh?

    Well it's a long story involving findwindow, getdc, and stuff like that.

    good luck!

    Hunted

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Add Msflex Grid control to your form.

    Module Code:

    Code:
    Public Const MAX_PATH = 260
    Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Public Type udtWin
        hWnd As Long
        ClassName As String
        Caption As String
    End Type
    Public tWin() As udtWin
    Public Function EnumWindowProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
        Dim strCaption As String
        Dim strClass As String
        Static i As Integer
        
        strCaption = Space(MAX_PATH)
        strClass = Space(MAX_PATH)
        Call GetClassName(hWnd, strClass, MAX_PATH)
        Call GetWindowText(hWnd, strCaption, MAX_PATH)
        
        'Strip off null character
        strCaption = Left(strCaption, InStr(strCaption, vbNullChar) - 1)
        strClass = Left(strClass, InStr(strClass, vbNullChar) - 1)
        
        'Add to array
        ReDim Preserve tWin(i)
        tWin(i).hWnd = hWnd
        tWin(i).ClassName = strClass
        tWin(i).Caption = strCaption
        
        i = i + 1
        'To cintinue, must return true
        EnumWindowProc = 1
    End Function
    Form Code:

    Code:
    Private Sub Form_Load()
        Dim i As Integer
        Dim strItem As String
        
        Call EnumWindows(AddressOf EnumWindowProc, &H0)
        
        MSFlexGrid1.Cols = 3
        MSFlexGrid1.TextMatrix(0, 0) = "hWnd"
        MSFlexGrid1.TextMatrix(0, 1) = "Class Name"
        MSFlexGrid1.TextMatrix(0, 2) = "Caption"
        
        For i = 0 To UBound(tWin)
            strItem = tWin(i).hWnd & vbTab & tWin(i).ClassName & vbTab & tWin(i).Caption
            MSFlexGrid1.AddItem strItem
        Next
        'Remove empty row
        MSFlexGrid1.RemoveItem 1
    End Sub
    This will enumerate all windows (including the ones on the background) and put them in a MsFlexGrid.


    Regards,
    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


    [This message has been edited by Serge (edited 11-15-1999).]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    87

    Post

    I just wanted to know how to get information from all Windows that are visible, and send information to a specific window....that's all.

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