Hey I have a answer machine
But when it ran,someting wrong happened.
Does anyone help me fix it.
I'm using VB6.




This is my wrong place.

And my code just like under.

Code:
Option Explicit
'CODED BY JOHN CASEY; [email protected]
'DONT FORGET REFERENCE TO "MICROSOFT HTML OBJECT LIBRARY"

Public Declare Function ObjectFromLresult Lib "oleacc" (ByVal lResult As Long, riid As UUID, ByVal wParam As Long, ppvObject As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessageTimeout Lib "user32" Alias "SendMessageTimeoutA" (ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As Any, ByVal fuFlags As Long, ByVal uTimeout As Long, lpdwResult As Long) As Long
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long

Type UUID
   Data1 As Long
   Data2 As Integer
   Data3 As Integer
   Data4(0 To 7) As Byte
End Type
   
Public Const SMTO_ABORTIFHUNG = &H2


Function getietext(ByVal hWnd As Long) As String
On Error Resume Next
Dim doc As IHTMLDocument2

If hWnd <> 0 Then
Set doc = IEDOMFromhWnd(hWnd)
Else
getietext = "-[TEXT CANNOT BE FOUND]-"
Exit Function
End If

'---CHECKS-FOR-HWND------


If doc.body.innerText = vbNullString Then
getietext = "ERROR! [WINDOW DOESN'T CONTAIN HTML]"
Exit Function
End If
'---CHECKS-FOR-HTML-EMBEDDED

getietext = doc.body.innerText

End Function

Function IEDOMFromhWnd(ByVal hWnd As Long) As IHTMLDocument
Dim IID_IHTMLDocument As UUID
Dim doc As IHTMLDocument2
Dim lRes As Long 'if = 0 isn't inet window.
Dim lMsg As Long
Dim hr As Long
'---END-DECLARES---------

' Register the message
            lMsg = RegisterWindowMessage("WM_HTML_GETOBJECT")
            
            ' Get the object
            Call SendMessageTimeout(hWnd, lMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes)


'---CHECKS-FOR-WINDOW----
hr = ObjectFromLresult(lRes, IID_IHTMLDocument, 0, IEDOMFromhWnd)

End Function
Is the
" lMsg = RegisterWindowMessage("WM_HTML_GETOBJECT")

' Get the object
Call SendMessageTimeout(hWnd, lMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes)" place wrong?

Because the "Function getietext(ByVal hWnd As Long) As String

On Error Resume Next
Dim doc As IHTMLDocument2

If hWnd <> 0 Then
Set doc = IEDOMFromhWnd(hWnd)
Else
getietext = "-[TEXT CANNOT BE FOUND]-"
Exit Function
End If
" place is my wrong.
So...please help me


And this is one aonther code.

Or is the" List1.AddItem " " & getietext(window(3)) & " @ " & Now" place wrong?

I really don't know how to do,please help me to fix it.

Code:
Private Sub Timer1_Timer()
Dim imclass As Long
imclass = FindWindow("ysearchmenuwndclass", vbNullString)
If imclass >= 1 Then
Pause (0.4)

Dim window(1 To 3) As Long
window(1) = FindWindow("ysearchmenuwndclass", vbNullString)
window(2) = FindWindowEx(window(1), 0, "ATL:0054E0E0", vbNullString)
window(3) = FindWindowEx(window(2), 0, "Internet Explorer_Server", vbNullString)
List1.AddItem " " & getietext(window(3)) & " @ " & Now

Pause (0.2)
YIM8ChatSend "answer:  " & Text1.Text & " "
Label1.Caption = Label1.Caption + 1
ClosePm
End If
End Sub