Hi, I'm trying to read text in a window, like an AOL window, and I want to be able to read and pick out certain words in the textbox. I'm able to read the whole sentence, but I can't pick out any words in the sentence. Here is my code:
VB Code:
' Find the window. lHwnd = FindWindow(vbNullString, "vegric") ' Find the chat box. lHwnd = FindWindowEx(lHwnd, ByVal 0&, "RichTextWndClass", vbNullString) 'allocate a 255 byte string; the first two bytes indicate the length strBuff = Chr$(255) & String$(256, vbNullChar) 'now this gets the last line of the textbox Call SendMessage(lHwnd, EM_GETLINE, SendMessage(lHwnd, EM_GETLINECOUNT, 0, ByVal 0&) - 2, ByVal StrPtr(strBuff)) 'convert the string to Unicode sWindowText = StrConv(strBuff, vbUnicode) MsgBox sWindowText 'below instead of saying 'if sWindowText = "hello"', I want to say something like if sWindowText CONTAINS "hello" If sWindowText = "hello" Then MsgBox ("The word 'hello' is in this sentence") End If
Thanks,
Brad




Reply With Quote