IPB

Welcome Guest ( Log In | Register )

4 Pages V   1 2 3 > »   
Reply to this topicStart new topic
> MSN Messenger 6 Programming - Visual Basic 6
Flammable
post Sep 27 2004, 11:09 PM
Post #1


Mess.bedbug
*

Group: Members
Posts: 28
Joined: 27-September 04
Member No.: 394



Creating an MSN Messenger 6 bot - By Flammable -- itsflammable--noreply.gif--hotmail.com

-----------------------------------------------------

Introduction:

After Microsoft released MSN Messenger 5 the entire programming community was sent into shock as they programs they had worked long and hard on were rendered useless, this was because windows messenger, the sister client of msn messenger had been released for corparate use and leaving the references enabled on this would increase the ammount of applications that could make the use of this better, while taking them from msn messenger would mean that it would be classed for more public use, unfortunately, windows messenger has a boring interface and non of the advantages that msn messenger 6 now has.

But, MSN Messenger 6 still can be programmed using Visual Basic 6 and contrary to believe, there is still quite alot that be done, although very limited considered to MSN Messenger 4.6.

This tutorial will deal on programming in Visual Basic 6. Visual Basic 6 is a microsoft product, see the microsoft website for more information.

Step 1:

Create a new project exe project in visual basic 6.

When this has been done, look in the menu at the top and click "Project", then click "References", then check the "Messenger API Type library", this is the simplist way to program an msn messenger 6 application.

Step 2:

Instead of typing messengerapi.messenger everytime we want to do a command we can simplify the ammount we have to type throughout our entire project by typing the following into the top of our project.
CODE

Public WithEvents msn As Messengerapi.Messenger

This should go at the very top of your starting form or in a module.

To let MSN Messenger know that you have done this in the event procedure form_load() add the following code.

CODE

Set msn = New Messengerapi.Messenger


If you started from blank the source code of your program should now look like the following:
CODE

Public WithEvents msn As Messengerapi.Messenger

Private Sub Form_Load()
Set msn = New Messengerapi.Messenger
end sub

Once this is done we are ready to begin programming.

Adding the contacts to a Listbox.

Create a listbox called list1.

I am going to create this example based that you have a list box and one command button on the form, when the command button clicks all the contacts email address's are thrown into the listbox.
CODE

private sub command1_click()
dim msncontact as imessengercontact
dim msncontacts as imessengercontacts
set msncontacts = msn.mycontacts
for each msncontact in msncontacts
list1.additem (msncontact.signinname)
next


Changing status to away.

Based on when a command button is clicked.
CODE

private sub command1_click()
msn.mystatus = msn.MyStatus = MISTATUS_AWAY
end sub

This can also be used to change the status to BRB, Busy, On the phone, Online etc..

This can be used to make a status bomber such as Popupz which i recently made.

Changing the nickname.

There is alot of ways which dont seem to work but the simplist way i have found if the sendkeys method, after not finding long complication methods to work that other people made examples, so i created this.
CODE

private sub command1_click()
msn.OptionsPages 0, MOPT_GENERAL_PAGE
Pause 0.5
SendKeys "New nickname here"
Pause 0.5
SendKeys "{ENTER}"
SendKeys "{ENTER}"
Me.Show
end sub

Sub Pause(interval)
Current = Timer
Do While Timer - Current < Val(interval)
DoEvents
Loop
End Sub
[B]Adding a contact:[/B]


CODE

private sub command1_click()
msn.AddContact 0, "example@hotmail.com"
SendKeys "{ENTER}"
Pause 1
SendKeys "{ENTER}"
end sub

Sub Pause(interval)
Current = Timer
Do While Timer - Current < Val(interval)
DoEvents
Loop
End Sub

Deleting a contact:
CODE

private sub command1_click()
dim msncontact as imessengercontact
dim msncontacts as imessengercontacts
set msncontacts = msn.mycontacts
Set MsgrContact = msn.GetContact("example@hotmail.com", msn.MyServiceId)
Call MsgrContacts.Remove(MsgrContact)
end sub

Signing Out:
CODE

private sub command1_click()
msn.signout ' simple
end sub

Sending a message to a contact:
CODE

private sub command1_click()
Set MsnWindow = msn.InstantMessage("example@hotmail.com") ' opens window
SendKeys "hello how are you?" 'this is the message to be sent
Pause 0.1
SendKeys "{ENTER}"
SendKeys "{ENTER}"
end sub

----------------------------------------------------------

This concludes my tutorial.

Flammable -- itsflammable--noreply.gif--hotmail.com
Go to the top of the page
 
+Quote Post
Stigmata
post Sep 28 2004, 10:31 AM
Post #2


Mess.betterthanyours
Group Icon

Group: Supervisor
Posts: 1,951
Joined: 5-September 04
From: Uk
Member No.: 79



Its a nice bot (thank you doggie)


nice and simple

thnx..

pinned?
Go to the top of the page
 
+Quote Post
ecko_complex
post Sep 29 2004, 05:31 AM
Post #3


MessengerDiscovery Creator
***

Group: Members
Posts: 118
Joined: 4-September 04
From: New Zealand
Member No.: 64



There's cleaner code out there (i.e by me msn_tongue.gif) to change the nick name.

C++
CODE
HWND msnmsblclass; //Declare the main MSN window HWND variable
HWND optionswindowclass; //Declare the options window HWND variable
HWND edithwnd; //Declare the edit box HWND variable

msnmsblclass = FindWindow("msnmsblclass", 0); //Find MSN Window
PostMessage(msnmsblclass, WM_COMMAND, 40268, 0); //Click the "Options menu item
optionswindowclass = FindWindow("#32770", "Options"); //Find the options window
optionswindowclass = FindWindowEx(optionswindowclass, 0, "#32770", 0);
edithwnd = FindWindowEx(optionswindowclass, 0, "edit", 0); //Find the editbox
SendMessage(edithwnd, WM_SETTEXT, 0,  (LPARAM)"Nick Name Here"); //Change the edit box to say "Nick Name Here"
PostMessage(edithwnd, WM_KEYDOWN, VK_RETURN, 0); //Push the enter key to close the dialog and set the nick name


VB 6 [module]
CODE
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Const WM_SETTEXT = &HC
Public Const WM_COMMAND = &H111
Public Const WM_KEYDOWN = &H100
Public Const VK_RETURN = &HD
Public Const WM_CHAR = &H102
Option Explicit

Public Function ChangeNick(nick As String)
''''''''''''''''''''''''''''''''''''''''''''
' Function: Change MSN Nick Name           '
''''''''''''''''''''''''''''''''''''''''''''
' Coder: effekt (ecko_complex)             '
''''''''''''''''''''''''''''''''''''''''''''
' Syntax: ChangeNick ("Desired Nick Name") '
''''''''''''''''''''''''''''''''''''''''''''

Dim msnmsblclass As Long 'Main MSN Window Variable
Dim edit As Long 'Edit Text Box Variable
Dim x As Long 'Options Window Variable

msnmsblclass& = FindWindow("msnmsblclass", vbNullString) 'Get Messenger Window HWND
PostMessage msnmsblclass&, WM_COMMAND, 40268, 0 'Show Options Box
x& = FindWindow("#32770", "Options") 'Get Options Box HWND
x& = FindWindowEx(x&, 0&, "#32770", vbNullString) 'Get Options Box HWND
edit& = FindWindowEx(x&, 0&, "edit", vbNullString) 'Get Edit Box HWND
SendMessageByString edit&, WM_SETTEXT, 0, nick 'Set Edit Box Text
PostMessage edit&, WM_KEYDOWN, VK_RETURN, 0 'Push Enter
PostMessage edit&, WM_KEYDOWN, VK_RETURN, 0 'Double Check :P - CUZ VB SUCKS

End Function

[promote MD]
Or you could just use the MessengerDiscovery API and not have to bother with the ugly dialog flashing ^_^.
[/promote MD]

This post has been edited by effekt: Sep 29 2004, 05:34 AM
Go to the top of the page
 
+Quote Post
Phoenix
post Sep 29 2004, 05:50 PM
Post #4


Mess.bean
*

Group: Members
Posts: 6
Joined: 29-September 04
From: Queens, New York
Member No.: 625



I'm new to messenger programming and I've utilized your tutorial (good info). How can I convert it to a dll or if you can point me to another tutorial to do this. I want to changes certain things on signin, etc.

thanx
msn_thinking.gif
Go to the top of the page
 
+Quote Post
Flammable
post Sep 29 2004, 07:23 PM
Post #5


Mess.bedbug
*

Group: Members
Posts: 28
Joined: 27-September 04
Member No.: 394



Hi phoenix, if your going to be using it for an addon / bot etc... you could put the code into functions and then put it into a module, although remember to use Public instead of Private.
Go to the top of the page
 
+Quote Post
Flammable
post Sep 29 2004, 07:25 PM
Post #6


Mess.bedbug
*

Group: Members
Posts: 28
Joined: 27-September 04
Member No.: 394



QUOTE(effekt @ Sep 29 2004, 06:31 AM)
There's cleaner code out there (i.e by me msn_tongue.gif) to change the nick name.

C++
CODE
HWND msnmsblclass; //Declare the main MSN window HWND variable
HWND optionswindowclass; //Declare the options window HWND variable
HWND edithwnd; //Declare the edit box HWND variable

msnmsblclass = FindWindow("msnmsblclass", 0); //Find MSN Window
PostMessage(msnmsblclass, WM_COMMAND, 40268, 0); //Click the "Options menu item
optionswindowclass = FindWindow("#32770", "Options"); //Find the options window
optionswindowclass = FindWindowEx(optionswindowclass, 0, "#32770", 0);
edithwnd = FindWindowEx(optionswindowclass, 0, "edit", 0); //Find the editbox
SendMessage(edithwnd, WM_SETTEXT, 0, (LPARAM)"Nick Name Here"); //Change the edit box to say "Nick Name Here"
PostMessage(edithwnd, WM_KEYDOWN, VK_RETURN, 0); //Push the enter key to close the dialog and set the nick name


VB 6 [module]
CODE
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Const WM_SETTEXT = &HC
Public Const WM_COMMAND = &H111
Public Const WM_KEYDOWN = &H100
Public Const VK_RETURN = &HD
Public Const WM_CHAR = &H102
Option Explicit

Public Function ChangeNick(nick As String)
''''''''''''''''''''''''''''''''''''''''''''
' Function: Change MSN Nick Name '
''''''''''''''''''''''''''''''''''''''''''''
' Coder: effekt (ecko_complex) '
''''''''''''''''''''''''''''''''''''''''''''
' Syntax: ChangeNick ("Desired Nick Name") '
''''''''''''''''''''''''''''''''''''''''''''

Dim msnmsblclass As Long 'Main MSN Window Variable
Dim edit As Long 'Edit Text Box Variable
Dim x As Long 'Options Window Variable

msnmsblclass& = FindWindow("msnmsblclass", vbNullString) 'Get Messenger Window HWND
PostMessage msnmsblclass&, WM_COMMAND, 40268, 0 'Show Options Box
x& = FindWindow("#32770", "Options") 'Get Options Box HWND
x& = FindWindowEx(x&, 0&, "#32770", vbNullString) 'Get Options Box HWND
edit& = FindWindowEx(x&, 0&, "edit", vbNullString) 'Get Edit Box HWND
SendMessageByString edit&, WM_SETTEXT, 0, nick 'Set Edit Box Text
PostMessage edit&, WM_KEYDOWN, VK_RETURN, 0 'Push Enter
PostMessage edit&, WM_KEYDOWN, VK_RETURN, 0 'Double Check :P - CUZ VB SUCKS

End Function

[promote MD]
Or you could just use the MessengerDiscovery API and not have to bother with the ugly dialog flashing ^_^.
[/promote MD]
[right][snapback]3730[/snapback][/right]


Hi thanks, im gonna test that now, from the code it looks like its gonna be good msn_happy.gif.

Update: O son, works so good. Thanks.

This post has been edited by Flammable: Sep 29 2004, 07:28 PM
Go to the top of the page
 
+Quote Post
Flammable
post Sep 29 2004, 08:07 PM
Post #7


Mess.bedbug
*

Group: Members
Posts: 28
Joined: 27-September 04
Member No.: 394



On second thoughts doesnt work msn_confused.gif, gets stuck on the options screen.
Go to the top of the page
 
+Quote Post
b0t13
post Sep 29 2004, 08:34 PM
Post #8


Mess.Newscout
***

Group: News Scout
Posts: 191
Joined: 28-September 04
From: Bob's BackGarden
Member No.: 535



thanks for that info Flammable its very helpful msn_happy.gif

ill try it out, if theres any errors ill let you know.
Go to the top of the page
 
+Quote Post
ecko_complex
post Sep 30 2004, 07:56 AM
Post #9


MessengerDiscovery Creator
***

Group: Members
Posts: 118
Joined: 4-September 04
From: New Zealand
Member No.: 64



I think theres an error in vb where the return key isn't sent (odd, I know) but in C++ it works seemlessly. You coild call the function twice or loop the
CODE

PostMessage edit&, WM_KEYDOWN, VK_RETURN, 0 'Push Enter

Until you get a zero from x in
CODE

x& = FindWindow("#32770", "Options") 'Get Options Box HWND

Oh a little note, you may notice in the code above that "Options" is hardcoded into it. This may get a little difficult on Messenger versions running other languages. i.e It will not find the Itilian version of the window because it will be called 'Opzioni' so you would then make the code
CODE

x& = FindWindow("#32770", "Opzioni") 'Get Options Box HWND

Same as with the C++ code as well msn_happy.gif.
Go to the top of the page
 
+Quote Post
Phoenix
post Sep 30 2004, 01:46 PM
Post #10


Mess.bean
*

Group: Members
Posts: 6
Joined: 29-September 04
From: Queens, New York
Member No.: 625



QUOTE(Flammable @ Sep 29 2004, 03:23 PM)
Hi phoenix, if your going to be using it for an addon / bot etc... you could put the code into functions and then put it into a module, although remember to use Public instead of Private.
[right][snapback]4021[/snapback][/right]

msn_up.gif I'll try that Flammable.
Go to the top of the page
 
+Quote Post
Flammable
post Sep 30 2004, 02:53 PM
Post #11


Mess.bedbug
*

Group: Members
Posts: 28
Joined: 27-September 04
Member No.: 394



QUOTE(effekt @ Sep 30 2004, 08:56 AM)
I think theres an error in vb where the return key isn't sent (odd, I know) but in C++ it works seemlessly. You coild call the function twice or loop the
CODE

PostMessage edit&, WM_KEYDOWN, VK_RETURN, 0 'Push Enter

Until you get a zero from x in
CODE

x& = FindWindow("#32770", "Options") 'Get Options Box HWND

Oh a little note, you may notice in the code above that "Options" is hardcoded into it. This may get a little difficult on Messenger versions running other languages. i.e It will not find the Itilian version of the window because it will be called 'Opzioni' so you would then make the code
CODE

x& = FindWindow("#32770", "Opzioni") 'Get Options Box HWND

Same as with the C++ code as well msn_happy.gif.
[right][snapback]4287[/snapback][/right]


Another problem ive found aswell is that when the options page is opened the new nickname isnt set and the old nickname just sits there.

The strange thing is the first time i tried it, it worked, then the second + time it didnt.
Go to the top of the page
 
+Quote Post
b0t13
post Sep 30 2004, 08:17 PM
Post #12


Mess.Newscout
***

Group: News Scout
Posts: 191
Joined: 28-September 04
From: Bob's BackGarden
Member No.: 535



very nice dude, thats definatly gonna get tested and maybe turned into a working program for myself.

cool thanks.
Go to the top of the page
 
+Quote Post
leekx1
post Oct 4 2004, 09:38 AM
Post #13


Mess.beanie
*

Group: Members
Posts: 11
Joined: 30-September 04
Member No.: 735



Hello mate i have Vb6 and i have a simple code justr to change your msn status to away.. But 1 thing it doesnt work.

i have go to refrences and changed it to messenger API type libary.

And this is the code i have used... : -

Public WithEvents msn As MessengerAPI.Messenger

Private Sub Form_Load()
Set msn = New MessengerAPI.Messenger
End Sub

Private Sub command1_click()
msn.MyStatus = msn.MyStatus = MISTATUS_AWAY
End Sub


Thats the code i used in VB6 just to change my status but when i clicked on F5 nothingh append A grey Form come up as Usual But no Change to my Msn Status ......

If anyone nows why this is can you reply.

Thanks Lee...

All help appriciated.! msn_wink.gif
Go to the top of the page
 
+Quote Post
Flaccid
post Oct 4 2004, 01:37 PM
Post #14


Mess.beanie
*

Group: Members
Posts: 12
Joined: 2-October 04
From: Eindhoven
Member No.: 783



haves some1 the complete source of an simple msn?
Go to the top of the page
 
+Quote Post
leekx1
post Oct 4 2004, 02:02 PM
Post #15


Mess.beanie
*

Group: Members
Posts: 11
Joined: 30-September 04
Member No.: 735



Mate can you send me a code of a simple thing and ill try it to see if it will work ...


add me X_MX3R_X@hotmail.com
Go to the top of the page
 
+Quote Post
b0t13
post Oct 4 2004, 05:13 PM
Post #16


Mess.Newscout
***

Group: News Scout
Posts: 191
Joined: 28-September 04
From: Bob's BackGarden
Member No.: 535



i used it and found a few errors but i resolved them rather quickly...pp.gif
Go to the top of the page
 
+Quote Post
Flammable
post Oct 9 2004, 09:08 PM
Post #17


Mess.bedbug
*

Group: Members
Posts: 28
Joined: 27-September 04
Member No.: 394



Can the admins / mods please make this a sticky.
Go to the top of the page
 
+Quote Post
timothy
post Oct 9 2004, 09:21 PM
Post #18



Group Icon

Group: Timothy
Posts: 771
Joined: 1-September 04
From: Netherlands
Member No.: 3



sticked up
Go to the top of the page
 
+Quote Post
doggie
post Oct 11 2004, 12:29 PM
Post #19


Shame on the ignorant
********

Group: Banned
Posts: 1,220
Joined: 6-October 04
From: Australia
Member No.: 1,062



QUOTE(Stigmata @ Sep 28 2004, 09:31 PM)
not excatly a bot, but more a client.....
nice and simple

thnx..

pinned?
[right][snapback]3376[/snapback][/right]

client? lol your kidding me? its called a bot, has no client like features other than send some messages.
Go to the top of the page
 
+Quote Post
nERDZ
post Oct 13 2004, 02:46 PM
Post #20


Mess.bean
*

Group: Members
Posts: 2
Joined: 13-October 04
Member No.: 1,621



does any1 have the vb code to change display pictures???
Go to the top of the page
 
+Quote Post

4 Pages V   1 2 3 > » 
Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 13th November 2018 - 04:20 PM
2004-2008 Seb Skuse, mess.be.
MessForum v6.1.4 - created for, and for use only by mess.be.