AuthorPostsRate it First!
Posted April 19, 2008 at 2:14 am #14029
Below is a link to a PDF tutorial showing how, step by step, to create a VB 2008 project to send text to a Paltalk chatroom.
VB2008PaltalkIntegration.zip (14.5 MB) Edit: link removed… content added below
Microsoft Visual Basic 2008 Express or greater
Paltalk – any working version
Application spy (almost any will work, but we will use JKs API Spy)
Edit: I have posted the different sections of the tutorial below.
Attachments:Posted April 20, 2008 at 1:10 pm #33580
Start a new project
Lets open VB 2008 and create a project.
Click on “Create” and then name the project “Send Text” (or whatever else you may want to call it).
After naming the project, click on “OK” and the project will open. Once you have an open project, save the project by going to “File” – “Save All” (make a note of were it is saving to).
Edit: added figures to postPosted April 20, 2008 at 1:11 pm #33579
Add modules and control to project
Now that we have the project saved, we can extract the contents of VB8PalProgramingComponents.zip to the project folder (in this case, “C:Documents and SettingsautopilotMy DocumentsVisual Studio 2008ProjectsSend TextSend Text”). This should give you a project folder content as below:
We must now add the downloaded files to the project in order to use them. Lets start with adding the modules! In VB 2008, go to “Project” – “Add Existing Item” and highlight all 4 of the mdl*.vb files and click “Add “.
After adding the files, they will be listed in the Solution Explorer and we can use their functions and subs in our project.
For those of you wondering what the purpose is of adding these modules to our project is, each module has been designed to do repeated tasks and so I have created the modules so that I don’t have to recreate the tasks in every program I make to integrate with Paltalk.
mdlGetHnd.vb Provides window handles mdlPalInfo.vb Provides Paltalk info through Properties mdlRegAccess.vb Provides Registry access (reads & writes) mdlSysListView.vb Provides SysListView32 integration
We will now add the last item that is in the “VB8PalProgramingComponents.zip”. It is “PalRoomSelector.dll”. To add this file, we must add it as a reference. Go to “Project” – “Add Reference” and select the browse tab. Select the “PalRoomSelector.dll” and click “OK”.
We now will add it to the toolbox so that we can easily place/use it on the form. To add it to the toolbox, go to “Tools” – “Choose Toolbox Items”.
Click on the “Browse” button and browse to the project folder and select the “PalRoomSelector.dll” and then click “Open”. Then click “OK” to finalize adding it to the toolbar. What does the “PalRoomSelector.dll” do? As its name suggests, it is a control to select an open Paltalk room to connect to.
Edit: added figures to postPosted April 20, 2008 at 1:12 pm #33578
Add ctrlRoomSelector to form
So lets add it to the form! Open the toolbox, find the ctrlRoomSelector, and drag it onto the form.
The ctrlRoomSelector width can be changed, but it will not allow you to change its height. The control has a fixed height of 40 and a default width of 374.
Now that we have added the roomselector, lets resize the form to be a bit wider and if you want, resize the roomselector to the size you want.
To activate the roomselector, it must be passed the class name of the chat room. Because we are using the mdlPalInfo, we can just pass the ChatRoomClass. We will do this in the form load event. Double click on the form and it will open the code view and add the Form1_Load event to the code. We now want to type in a command to pass the class name to the roomselector. The
ctrlRoomSelector has a “SetWinClass” method used like: Me.CtrlRoomSelector1.SetWinClass(mdlPalInfo.ChatRoomClass)
Once the SetWinClass is exicuted the first time, it will cause the control to refresh and fill the combobox with a list of all open Paltalk rooms. So your code should look like :
Lets run the project to see if the roomselector will work. To run in debug mode, click on the green arrow on the toolbar.
If one or more Paltalk rooms are open, then they should populate the control. If no Paltalk rooms are open, the control should be blank. Open or close rooms and see the changes in the dropdown list of the roomselect control. Once you are done testing that the control is working, close the running project by clicking on the X in the top right corner.
Edit: Added figures to postPosted April 20, 2008 at 1:14 pm #33577
Add SendText functionality to project
Now that we can easily select which Paltalk room we want to work with, lets add some functionality to our project. Lets send text to the selected Paltalk room! To do this, lets add a Text box to the form that we can type into and a button that will send our message to the room.
Switch back to the design view, open the toolbox (if it is not expanded), select “TextBox” and drag it onto the form. Then do the same thing with “Button”.
Double click on the button to add code to the button click event. To make the button click send the text from the textbox to the selected Paltalk room, we must find the handle of the Richedit control in the Paltalk client. To do this, there are many different ways that can be taken. The way I will show here is:
Find the handle of the splitter window that contains the richedit control
Use splitter window handle to find the richedit control
Using SubFormHndByClassNameWithMWClassWithPartialMWCaption of the mdlGetHnd, get a handle for the splitter window.
Using SubFormHndByClassNameWithMWHnd of the mdlGetHnd, get a handle for the richedit control.
Each of the steps above will return an integer, so we must first create an integer object to receive the data.
Dim iHnd As Integer
Then we need to call our function to get the splitter window handle. mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption requires 4 pieces of information to find the correct handle.
1.) Class name of the parent window (mdlPalInfo.ChatRoomClass)
2.) Caption text of the parent window (our selected room name)
3.) Class name of the subwindow (mdlPalInfo.SplitterClass)
4.) Index from the parent window (mdlPalInfo.SplitterIndex)
So we end up with the following:
iHnd = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.CtrlRoomSelector1.RoomName, mdlPalInfo.SplitterClass, mdlPalInfo.SplitterIndex)
We are now ready to Find the richedit handle. mdlGetHnd.SubFormHndByClassNameWithMWHnd requires 3 pieces of information to find the correct handle.
1.) Handle of the parent window (iHnd from previous step)
2.) Class name of the subwindow (mdlPalInfo.ChatTextClass)
3.) Index from the parent window (mdlPalInfo.SendTextIndex)
So we end up with the following:
iHnd = mdlGetHnd.SubFormHndByClassNameWithMWHnd(iHnd, mdlPalInfo.ChatTextClass, mdlPalInfo.SendTextIndex)
Now that we have the handle to the richedit box, we can use it to send the text to the Paltalk client. We will use the “SendMessageByString” API to send the text. This API is configured in the mdlGetHnd module so we do not need to do anything more to use it (except call it correctly). This API also returns an integer, so let us configure an integer object to receive the return form “SendMessageByString”.
Dim iResult As Integer
We need to now send our text followed by the enter key press and release. The “SendMessageByString requires 4 pieces of information to send a message.
1.) Handle of control to send message to (iHnd from previous step)
2.) Type of message as integer (constants we will define in a moment)
3.) wParam as an integer
4.) lParam as a string (our text)
For sending text, the type of message is WM_SETTEXT
For sending key press, the type of message is WM_KEYDOWN
For sending key release, the type of message is WM_KEYUP
The wParam for sending text is 0
The wParam for sending enter key press is VK_Return
The wParam for sending enter key release is VK_Return
We must define the above constants as:
Const WM_SETTEXT As Integer = &HC
Const WM_KEYDOWN As Integer = &H100
Const WM_KEYUP As Integer = &H101
Const VK_Return As Integer = &HD
After the constants are set up, we can make our SendTextByString calls. Send the text:
iResult = SendMessageByString(iHnd, WM_SETTEXT, 0, Me.TextBox1.Text)
Send the enter key press:
iResult = SendMessageByString(iHnd, WM_KEYDOWN, VK_Return, 0)
Send the enter key release:
iResult = SendMessageByString(iHnd, WM_KEYUP, VK_Return, 0)
Run the project in debug mode to test it (use green arrow on toolbar). Select a room, type into the text box, and click on button 1
If you followed the instructions, you will have your text post into the selected room.
This has been a basic overview of how to send text to a Paltalk room. While it does work, there are some inherent limitations on what this code can do. To add more functionality to sending text, search the Locohacker.net forums for more help.
You can now play with some of the other things included in the modules that are part of the project.
I did not use the mdlSysListView, but you can use it to find and/or highlight a nic in the room nic list.
With the mdlRegAccess, you can save your program settings to the registry or read any registry value you need.
The mdlGetHnd has other methods to find handles, but the 2 I used in this example are the ones that will be most often needed.
Edit: Added figures to postPosted April 20, 2008 at 1:17 pm #33576
Finding a Controls index value
Previously we saw that the method used in this example to find a handle for a subwindow required an index value. How does one go about finding that? Why did we use a 2 step process to find the handle of the richedit control in the Paltalk client?
To find the index value, one can use a Spy program. With a Paltalk room open, open the JK’s API Spy and click on the “Tree” tab (you may wish to expand the window a bit).
Put the mouse pointer on the yellow circle and drag it over onto the Paltalk client text box that you send text from.
This gives you a list of all the controls with their handles from the parent all the way down to the selected control (Shown with the yellow triangle!)
You can expand all the sibling nodes above and then count the number of times the control you are looking for shows up from the parent control down to destination. So first we find the splitter control that holds the richedits. In my example, I am using Paltalk 8.5. The Main Paltalk window class is “My Window Class”. So we can count the “WTL_SplitterWindow” and find that for Paltalk 8, the splitter control index is 3. Once we have this, we can start at the third splitter control (it is our new parent) and count the “RichEdit20A” controls down to the send text control (with the yellow triangle!). We can see that for Paltalk 8 the send text index is 3
Now why would we want to do the handle search in 2 steps? Why not just find the index for the richedit control with the main window as the parent? That is exactly what I used to do until Paltalk 9.4 was released. The index value from the main window to the richedit control is different for a black nic then a purchased nic in Paltalk 9.4. But the main windoe to the splitter control is the same for all nics and from the splitter to the richedit is the same for all nics. So to make my programs work with any version of the Paltalk client, I have used the 2 step approach. Using the 1 step approach, would require more coding and checking to determine if Paltalk is 9.2 and below or 9.4 and above as well as if the user is a black nic or not and then set up variables based on the findings. Doable, but more work!
Edit: Added figure to postPosted July 1, 2008 at 5:27 am #33582
Great tutorials!!! I’m trying to make some .NET apps for PalTalk, I’ve try several version but It seem to me that the RoomSelector will not works on the latest PT version 9 build 254. I wonder if there and update for this?
Again, thanks for take the time make these great tutorials.
J5Posted July 1, 2008 at 10:25 am #33583AdministratorPosts: 1093
Latest build is 253 as far as I know.
Waiting on gerber…Posted July 1, 2008 at 1:37 pm #33584
build 253 is the current version that you donload from Pal (not bata) and it is working fine with it for me!Posted July 1, 2008 at 2:57 pm #33585
yes I was mistaken, it is 253Posted July 1, 2008 at 9:28 pm #33586
I dont know why it will not work for you with pal 9.4 build 253…
Like I said… it works great for me with pal 9.4 build 253…
Maybe look at how you are calling it??????? just a guess…Posted July 2, 2008 at 5:11 am #33587
Sorry I missed an important step, set ChatRoomClass 😳
it works great!!!Posted September 1, 2008 at 2:58 pm #33588AdministratorPosts: 387
Thank you … this is a very helpful article.Posted January 14, 2009 at 8:11 pm #33589MemberPosts: 4244
Great work, I hope it stats me off on the right pathPosted February 18, 2009 at 5:30 pm #33590AdministratorPosts: 4708
Thanks Auto 🙂 I am working on a program now ehhehe, hey one thing how to go about getting the index to get the last line
I am stuck and want to see if I can convert this to connect to the last line index instead of the send text index
Dim iHnd As Integer iHnd = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.CtrlRoomSelector1.RoomName, mdlPalInfo.SplitterClass, mdlPalInfo.SplitterIndex) iHnd = mdlGetHnd.SubFormHndByClassNameWithMWHnd(iHnd, mdlPalInfo.ChatTextClass, mdlPalInfo.SendTextIndex) Dim iResult As Integer iResult = SendMessageByString(iHnd, WM_SETTEXT, 0, Me.RichTextBox1.Rtf) iResult = SendMessageByString(iHnd, WM_KEYDOWN, VK_Return, 0) iResult = SendMessageByString(iHnd, WM_KEYUP, VK_Return, 0)
You must be logged in to reply to this topic.