dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: I would like to retrieve chat text from this Window to a text box in my application

  1. #1
    Join Date
    Dec 2005
    Posts
    3

    Post [vb.net 2017] VI would like to retrieve chat text from this Window to a text box

    [vb.net 2017]

    Hi every one
    I need help getting some text from a chatroom in chatten.dk, i have made a program in visual basic 6 before but the code is gone i can't find it. now i try in visual studio 2017 vb.net but i can't remember how but in the old internet exlore it was shown something with "IEFrame" and "shell docobject view" and after that the internet "explorer_server" but today it seems like it has become more complicated.


    Here's my code

    Public Class Win32

    #Region "Methods and functions Declaration"
    Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32

    Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
    Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As Int32, ByVal hWndChildAfter As Int32, ByVal lpszClass As String, ByVal lpszWindow As String) As Int32
    Public Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Int32) As Int32
    Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
    Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As String) As Int32
    Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As System.Text.StringBuilder) As Int32

    #End Region
    #Region "Messages"
    Public Const WM_GETTEXT As Int32 = &HD
    Public Const WM_SETTEXT As Int32 = &HC
    Public Const WM_GETTEXTLENGTH As Int32 = &HE


    #End Region
    End Class

    Imports System.Runtime.InteropServices

    Public Class Frmwin32


    Private Sub Frmwin32_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
    Dim Hwnd As Integer = Win32.FindWindow(Nothing, "Chatten.dk | Den Sejeste Gratis Chat Online! - Internet Explorer")
    Dim Chwnd As Integer = Win32.FindWindowEx(Hwnd, Nothing, "WorkerW", Nothing)
    Dim Chwnd1 As Integer = Win32.FindWindowEx(Chwnd, Nothing, vbNullString, Nothing)
    Dim Chwnd2 As Integer = Win32.FindWindowEx(Chwnd1, Nothing, "Chatten.dk | Den Sejeste Gratis Chat Online! - Internet Explorer", Nothing)
    Dim Chwnd3 As Integer = Win32.FindWindowEx(Chwnd2, Nothing, vbNullString, Nothing)
    Dim Chwnd4 As Integer = Win32.FindWindowEx(Chwnd3, Nothing, vbNullString, Nothing)
    Dim count As Integer
    Dim sb As System.Text.StringBuilder
    If (Not Hwnd = 0 And Not Chwnd = 0 And Not Chwnd1 = 0 And Not Chwnd2 = 0 And Not Chwnd3 = 0 And Not Chwnd4 = 0) Then
    'Win32.ShowWindow(Hwnd)
    'SendKeys.Send("Hello")
    'Win32.SetForegroundWindow(Chwnd)
    count = Win32.SendMessage(Chwnd4, Win32.WM_GETTEXTLENGTH, 0, 0)
    sb = New System.Text.StringBuilder(count + 1)
    Win32.SendMessage(Chwnd4, Win32.WM_GETTEXT, sb.Capacity, sb)
    MessageBox.Show(sb.ToString)
    Else
    MessageBox.Show("Handler Not Found")
    End If

    End Sub
    End Class

    Name:  the chat.jpg
Views: 68
Size:  52.9 KB - Name:  spy++6.jpg
Views: 68
Size:  38.8 KB
    Last edited by megabit; April 11th, 2019 at 11:01 AM.

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)