Results 1 to 3 of 3

Thread: Reading text from an open web browser tab

  1. #1

    Thread Starter
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Reading text from an open web browser tab

    I am trying to read a chat window from a web browser tab that the user will already have open (for example, the user could have a Twitch stream open in the background, and the program would be scanning chat to do things like "notify the user when someone mentions their name").

    In the past I have used the FindWindow API (for instance to get the handle of a notepad window) then using the FindWindowEx API to get the handle of the actual text box in notepad, then use the SendMessage API (using "WM_GETTEXT") to get the actual text.

    vb Code:
    1. Private Const WM_GETTEXT As Integer = &HD
    2. Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    3.     <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    4. Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, ByVal childAfter As IntPtr, ByVal lclassName As String, ByVal windowTitle As String) As IntPtr
    5.     End Function
    6. Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

    The FindWindow API works in this instance, but I don't know the class name of the "webpage viewing object" on the window of the web browser. Then I need to somehow extract the chat log. Any ideas? Thanks so much!

    (I am testing things with the Brave web browser but am open to using any browser if we can get it working.)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Reading text from an open web browser tab

    You generally use a tool like Spy++, WinID or Winspector to determine things like window hierarchy and class names.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: Reading text from an open web browser tab

    Thank you! I used those programs, and clearly this API method will not work. Does anyone have any other ideas?

Tags for this Thread

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