Skip to content

Paltalking (any version) with VB 2005 Express Beta

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #189406
    mightythor
    Member

    I would have preferred to zip up my project and attach it, or stick it in the download area, but I didn’t see how. Sorry if this violates etiquette.

    I am using Visual Basic 2005 Express Beta. I think you will find the code interesting. I have not written anything that has not been accomplished before in different ways. I wrote yet another routine to write to Paltak for a specific group name, in Version 8. Big Woop. But I think you will find the use of collections, classes, and recursion worth a look. These are three things that were greatly improved in the new Visual Basic. Special thanks to loco for coming up with the idea to declare a richtextbox to do formatting.

    This code should work for any Paltalk verson. Let me know if I am wrong.


    Imports System.Collections.Generic
    Public Class HandleGrabber

    ' ********** Well I do declare **********
    Declare Function GetWindow Lib "user32" (ByVal hwnd As Int32, ByVal wCmd As Int32) As Int32
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Int32, ByVal lpClassName As String, ByVal nMaxCount As Int32) As Int32
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
    Public Declare Function SendMessageByString Lib "USER32" 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" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32

    Public Const GW_CHILD = 5
    Public Const GW_HWNDNEXT = 2

    Public Const WM_LBUTTONDOWN As Int32 = &H201
    Public Const WM_LBUTTONUP As Int32 = &H202
    Public Const WM_SETTEXT As Int32 = &HC
    Public Const WM_GETTEXT As Int32 = &HD
    Public Const VK_RETURN As Int32 = &HD
    Public Const WM_KEYDOWN As Int32 = &H100
    Public Const WM_KEYUP As Int32 = &H101

    Public Const TextBoxParentClass As String = "#32770"
    Public Const TextBoxClass As String = "RichEdit20A"
    Public Const TextBoxIndex As Int32 = 2

    Public Const GroupName As String = "MyCoolGroup - Voice Room"
    Public Const GroupClass As String = "My Window Class"

    Private Sub HandleGrabber_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim ChatStream As OutputStream
    ChatStream = New OutputStream(GroupClass, GroupName)
    ChatStream.SendText(ChatStream.ChatHandle, "It works! (w)", "Courier New", Color.Orange, 12, FontStyle.Bold)
    Application.Exit()
    End Sub
    Public Class Window
    Public ChatRoom As Frame
    Public ChatHandle As Int32
    Sub New(ByVal WindowClass, ByVal WindowName)
    ' add the initial frame to the window tree
    ' because of recursion, this call then builds the entire tree
    ChatRoom = New Frame(FindWindow(WindowClass, WindowName))
    ChatHandle = GetSendTextHandle(ChatRoom)
    End Sub
    ' This frame objects refers to any subsection of a window, including the whole window.
    ' It includes a pointer (Branch) to each of its child frames.
    ' the child frames are sorted by class name for easier access.
    Public Class Frame
    Public Handle As Int32 = 0
    Public Name As String = Space(256)
    Public RegClass As String = Space(256)
    Public Branch As Dictionary(Of String, List(Of Frame)) = Nothing
    Sub New(ByVal FrameHandle As Int32)
    Dim NameLen, ClassLen As Int32
    Handle = FrameHandle

    NameLen = GetWindowText(Handle, Name, 255)
    ClassLen = GetClassName(Handle, RegClass, 255)

    Name = Name.Substring(0, NameLen)
    RegClass = RegClass.Substring(0, ClassLen)

    If Handle > 0 Then
    Call AddBranch()
    End If
    End Sub

    ' gets all the frame nodes for a parent frame
    Public Sub AddBranch()
    Dim NodeHandle As Int32
    NodeHandle = GetWindow(Handle, GW_CHILD)

    Branch = New Dictionary(Of String, List(Of Frame))
    Do While NodeHandle > 0
    AddNode(NodeHandle)
    NodeHandle = GetWindow(NodeHandle, GW_HWNDNEXT)
    Loop
    End Sub
    'Sticks a frame into its corresponding branch
    Public Sub AddNode(ByVal NodeHandle As Int32)
    Dim FrameNode As Frame
    FrameNode = New Frame(NodeHandle)

    If Not Branch.ContainsKey(FrameNode.RegClass) Then
    Branch.Add(FrameNode.RegClass, New List(Of Frame))
    End If
    Branch(FrameNode.RegClass).Add(FrameNode)

    End Sub
    End Class
    ' after the window tree is built, this finds the send text frame and returns its handle
    Public Shared Function GetSendTextHandle(ByVal CurrentFrame As Frame) As Int32
    Dim KVP As KeyValuePair(Of String, List(Of Frame))
    Dim F As Frame
    Dim I As Int32

    For Each KVP In CurrentFrame.Branch
    I = 0
    For Each F In CurrentFrame.Branch(KVP.Key)
    If CurrentFrame.RegClass = TextBoxParentClass Then
    If KVP.Key = TextBoxClass Then
    I = I + 1
    If I = TextBoxIndex Then
    Return (F.Handle)
    End If
    End If
    End If
    If GetSendTextHandle > 0 Then Return (GetSendTextHandle)
    GetSendTextHandle = GetSendTextHandle(F)
    Next F
    Next KVP

    End Function
    End Class

    Private Class OutputStream
    Public ChatRoom As Window
    Public ChatHandle As Int32
    Public RTB As RichTextBox

    Sub New(ByVal WindowClass As String, ByVal WindowName As String)
    ChatRoom = New Window(WindowClass, WindowName)
    ChatHandle = ChatRoom.ChatHandle

    RTB = New RichTextBox

    ' pull the handle to the send text box out of the tree
    If IsNothing(ChatRoom) Then
    MsgBox("Could not find an open window named: " & GroupName)
    Else
    If ChatRoom.ChatHandle = 0 Then
    MsgBox("Could not find the text box in: " & GroupName)
    End If
    End If

    End Sub
    Public Function SendText(ByVal SendTextBox As Int32, ByVal TheText As String, ByVal FontName As String, ByVal ColorValue As System.Drawing.Color, ByVal Size As Int32, ByVal Style As System.Drawing.FontStyle)
    Dim Status

    'Paltalk will take anything greater than 12 and make it 10, so I make it 12
    If Size > 12 Then Size = 12

    RTB.SelectedText = TheText
    RTB.SelectAll()
    RTB.SelectionFont = New Font(FontName, Size, Style)
    RTB.SelectionColor = ColorValue

    Status = SendMessageByString(SendTextBox, WM_SETTEXT, Nothing, RTB.Rtf)
    If (Status > 0) Then
    Status = SendMessage(SendTextBox, WM_KEYDOWN, VK_RETURN, Nothing)
    End If

    If (Status) Then
    MsgBox("Write to chatroom failed.")
    End If

    Return (Status)
    End Function

    End Class

    End Class

    Create a project and then paste this code into it. Enjoy.

    Andrew 🙂

    #189411
    Johnny5
    Member

    wonder if you could do for vb.net?

    #189410
    Admin
    Administrator

    OMG I think this exactly what i am looking for 🙂

    hey mightythor if u ever pass bye can u attach the file lol is tha u need to be trusted member to attach file.

    now u are 🙂

    #189409
    mightythor
    Member

    Um, like, here it is, and stuff.

    #189408
    Admin
    Administrator

    Perfect. thanks a lot this is great work 🙂

    #189407
    method
    Member

    could i run this project in visual studio 2003 ? By the way what does this code ? is it a new paltalk ?Thanks

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.