VB 2008 Paltalk Integration

Here you will find tutorials that will help you with programming.

VB 2008 Paltalk Integration

Postby autopilot » Fri Apr 18, 2008 9:14 pm


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

Requirements:
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
VB8PalProgramingComponents.zip
(17.7 KiB) Downloaded 232 times
Last edited by autopilot on Sun Apr 20, 2008 9:08 am, edited 1 time in total.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Sun Apr 20, 2008 8:10 am

Start a new project
Lets open VB 2008 and create a project.

Figure1.PNG
figure 1
Figure1.PNG (1.7 KiB) Viewed 3346 times


Click on “Create” and then name the project “Send Text” (or whatever else you may want to call it).

Figure2.PNG
figure 2


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).

Figure3.PNG
figure 3
Figure3.PNG (7.42 KiB) Viewed 3349 times


Edit: added figures to post
Last edited by autopilot on Sun Apr 20, 2008 9:01 am, edited 2 times in total.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Sun Apr 20, 2008 8:11 am

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 Settings\autopilot\My Documents\Visual Studio 2008\Projects\Send Text\Send Text”). This should give you a project folder content as below:

Figure4.PNG
figure 4


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 “.

Figure5.PNG
figure 5


After adding the files, they will be listed in the Solution Explorer and we can use their functions and subs in our project.

Figure6.PNG
figure 6
Figure6.PNG (4.62 KiB) Viewed 3344 times


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”.

Figure7.PNG
figure 7
Figure7.PNG (11.02 KiB) Viewed 3344 times


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”.

Figure8.PNG
figure 8


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 post
Last edited by autopilot on Sun Apr 20, 2008 8:45 am, edited 1 time in total.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Sun Apr 20, 2008 8:12 am

Add ctrlRoomSelector to form
So lets add it to the form! Open the toolbox, find the ctrlRoomSelector, and drag it onto the form.

Figure9.PNG
figure 9


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 :

Figure10.PNG
figure 10
Figure10.PNG (6.8 KiB) Viewed 3340 times


Lets run the project to see if the roomselector will work. To run in debug mode, click on the green arrow on the toolbar.

Figure11.PNG
figure 11
Figure11.PNG (748 Bytes) Viewed 3331 times


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 post
Last edited by autopilot on Sun Apr 20, 2008 8:50 am, edited 1 time in total.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Sun Apr 20, 2008 8:14 am

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”.

Figure12.PNG
figure 12


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

Step 1:
Using SubFormHndByClassNameWithMWClassWithPartialMWCaption of the mdlGetHnd, get a handle for the splitter window.
Step 2:
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)

Figure13.PNG
figure 13


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.

Figure14.PNG
figure 14
Figure14.PNG (5.64 KiB) Viewed 3325 times


If you followed the instructions, you will have your text post into the selected room.

Figure15.PNG
figure 15
Figure15.PNG (9.48 KiB) Viewed 3327 times


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 post
Last edited by autopilot on Sun Apr 20, 2008 8:56 am, edited 1 time in total.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Sun Apr 20, 2008 8:17 am

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.

Figure16.PNG
figure 16


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!

Happy coding!

Edit: Added figure to post
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby Johnny5 » Tue Jul 01, 2008 12:27 am

HI pilot,

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.

J5
Johnny5
imFiles Junior
imFiles Junior
 
Posts: 72
Joined: Wed Dec 29, 2004 7:16 pm

Re: VB 2008 Paltalk Integration

Postby Chike » Tue Jul 01, 2008 5:25 am

Latest build is 253 as far as I know.
Waiting on gerber...
Image
Chike
imFiles Master
imFiles Master
 
Posts: 581
Joined: Sun May 13, 2007 6:20 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Tue Jul 01, 2008 8:37 am

build 253 is the current version that you donload from Pal (not bata) and it is working fine with it for me!
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby Johnny5 » Tue Jul 01, 2008 9:57 am

yes I was mistaken, it is 253
Johnny5
imFiles Junior
imFiles Junior
 
Posts: 72
Joined: Wed Dec 29, 2004 7:16 pm

Re: VB 2008 Paltalk Integration

Postby autopilot » Tue Jul 01, 2008 4:28 pm

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...
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: VB 2008 Paltalk Integration

Postby Johnny5 » Wed Jul 02, 2008 12:11 am

Sorry I missed an important step, set ChatRoomClass :oops:

it works great!!!
Johnny5
imFiles Junior
imFiles Junior
 
Posts: 72
Joined: Wed Dec 29, 2004 7:16 pm

Re: VB 2008 Paltalk Integration

Postby NVYE » Mon Sep 01, 2008 9:58 am

Thank you ... this is a very helpful article.
Add-on Bots for educational and amusement purposes:
http://www.vipbots.com

Website:
http://www.asktechguy.com
User avatar
NVYE
imFiles Senior
imFiles Senior
 
Posts: 230
Joined: Fri Jun 10, 2005 11:29 pm

Re: VB 2008 Paltalk Integration

Postby ION-8 » Wed Jan 14, 2009 3:11 pm

Great work, I hope it stats me off on the right path
ION-8
imFiles Newbie
imFiles Newbie
 
Posts: 34
Joined: Tue Dec 23, 2008 8:07 pm

Re: VB 2008 Paltalk Integration

Postby locohacker » Wed Feb 18, 2009 12:30 pm

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
Code: Select all
        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)
User avatar
locohacker
Site Admin
Site Admin
 
Posts: 4325
Joined: Fri Dec 31, 2004 6:59 pm

Next

Return to Programming Tutorials

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests