Results 1 to 3 of 3

Thread: Trying to get the handle of an AIM Window

  1. #1

    Thread Starter
    Junior Member SkettaLEE's Avatar
    Join Date
    Oct 2001
    Location
    Shaw AFB, SC
    Posts
    30

    Exclamation Trying to get the handle of an AIM Window

    Im trying to get the handle of an AIM window....... and get the text the person sends.... im makin an AFK bot and it aint workin out..... this is my code... check it

    Code:
        Dim vLines As Variant
        findstring$ = "Instant Message"
        findstring2$ = "Conversation"
        Dim h As Long, a As String, j As Long, k As Long, bFound As Boolean
        h = GetWindow(GetDesktopWindow(), GW_CHILD)
    
    
        Do While h
            a = Space$(128)
            j = SendMessage(h, WM_GETTEXT, 128, ByVal a)
            
                If j Then
                a = Left$(a, j)
                
                If InStr(a, findstring$) <> 0 Then
                    SN = a
                    Handle = h
                    Exit Do
                End If
                
                End If
                
            h = GetWindow(h, GW_HWNDNEXT)
        Loop
        
    
    
    
    Do
    Text2$ = GetClass(Win%)
    MsgBox Text2$
    If Text2$ = "Ate32Class" Then Exit Do
    If Text2$ = "RichEdit20A" Then Exit Do
    
    Win% = GetWindow(Win%, GW_HWNDNEXT)
    Loop Until Win% = 0
    
    WinEdit% = GetWindow(Win%, GW_HWNDNEXT)
    WinEdit% = GetWindow(WinEdit%, GW_HWNDNEXT)
    Text2$ = GetClass(WinEdit%)
    MsgBox Text2$
    
    
    Text& = SendMessage(Win%, WM_GETTEXTLENGTH, 0&, 0&)
    Cursor$ = String(Text&, 0&)
    Call SendMessageByString(Win%, WM_GETTEXT, Text& + 1, Cursor$)
    If Cursor$ = DogImCountingn Then Exit Sub
    DogImCounting = Cursor$
    
        Do While InStr(Cursor$, ":")
            d = InStr(Cursor$, ":")
            LastOfIt = Mid$(Cursor$, d + 1, Len(Cursor$))
            If InStr(LastOfIt, ":") = False Then
                Exit Do
            Else
                Cursor$ = LastOfIt
            End If
        Loop
    Cursor$ = Right$(LastOfIt, Len(LastOfIt) - 2)
    
    ' This is the line of code that does the commands for
    ' whatever the user types in
    MsgBox Cursor$
    If InStr(Cursor$, "end") Then End
    If InStr(Cursor$, "Say It") Then
    SendMessage WinEdit%, WM_SETTEXT, ByVal 0, "Im Busy"
    End If

    Someone please help me out!!
    This is our world now, The world of the pop-trunk and the switch.
    The beauty of my Broad :-)
    We wage wars, murder, cheat, lie to our women and make them believe its for their own good. And we're the criminals.
    My crime is but of pimpology.
    I am a Pimp, and this is my manefesto!

  2. #2
    Jordan
    Guest
    Make sure you have the FindWindow and FindWindowEx API functions declared.
    Code:
    Public Function FindIM() As Long
        FindIM = FindWindow("AIM_IMessage", vbNullString)
    End Function
    You can use this along with FindWindowEx (supplying the previous IM handle as the starting point) to get the handles of all open IM windows.

    To get the IM text, use the IM handle and pass it to the FindTextTop Function:
    Code:
    Public Function FindTextTop(IMHandle As Long) As Long
    Dim AteClass2 As Long
    Dim WndAteClass As Long
    WndAteClass = FindWindowEx(IMHandle, 0, "WndAte32Class", vbNullString)
    AteClass2 = FindWindowEx(WndAteClass, 0, "Ate32Class", vbNullString)
    FindTextTop = AteClass2
    End Function
    This will return the handle to the conversation part of the IM window. Finally, you will need to Get the text from the TextTop hWnd. Make sure you declare API functions SendMessageLong and SendMessageByString, and the constants WM_GETTEXTLENGTH and WM_GETTEXT.
    Code:
    Public Function GetText(Window As Long) As String
    Dim Buffer As String, Length As Long
    
        Length = SendMessageLong(Window, WM_GETTEXTLENGTH, 0, 0)
        Buffer = String(Length, 0)
        Call SendMessageByString(Window, WM_GETTEXT, Length + 1, Buffer)
        GetText = Buffer
    
    End Function
    In summary, use the FindIM function to get the IM handle, pass the IM handle to the FindTextTop function to get the handle of the IM convo, and use GetText by passing the return of FindTextTop.

  3. #3

    Thread Starter
    Junior Member SkettaLEE's Avatar
    Join Date
    Oct 2001
    Location
    Shaw AFB, SC
    Posts
    30

    ok but...

    What version of VB are you using? Also...... What do you do with FindWIndowEx
    This is our world now, The world of the pop-trunk and the switch.
    The beauty of my Broad :-)
    We wage wars, murder, cheat, lie to our women and make them believe its for their own good. And we're the criminals.
    My crime is but of pimpology.
    I am a Pimp, and this is my manefesto!

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