Fanatic Live: MessengerAPI without Windows Messenger - Fanatic Live

Jump to content

  • (10 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

MessengerAPI without Windows Messenger Rate Topic: ****- 4 Votes

#1 User is offline   TheSteve

  • The Man from Japan
  • Icon
  • Group: Moderators
  • Posts: 1,813
  • Joined: 07-May 05
  • Location:Fukuoka, Japan
  • Interests:Computer Programming

Posted 25 September 2006 - 12:55 AM

I was playing around with the Messenger API the other day and decided I wanted to figure out how to stop Windows Messenger from starting up. Needless to say, I figured it out and I have constructed a new type library that everyone can use.

How to use:
The easiest way to use it is to go to the references in your favorite programming language. Select browse, and then select the type library I am attaching to this post. This will add a new item to your references list called "MSN Messenger API Type Library" (Note the added "MSN" in front to avoid confusion)

Then use the API pretty much exactly the same as you normally would. If you have any questions or problems, post them here.

EDIT: Updated to fix problems with C++ wrapper generation.

Attached File(s)


0

#2 User is offline   david_ES

  • Fanatic Fly
  • Icon
  • Group: Valued Members
  • Posts: 52
  • Joined: 20-July 05
  • Location:Canary Islands, Spain

Posted 25 September 2006 - 09:01 AM

This file works in .NET?
0

#3 User is offline   vikke

  • Mr One Hundred
  • PipPipPipPip
  • Group: Members
  • Posts: 178
  • Joined: 07-September 05

Posted 25 September 2006 - 12:59 PM

Yes, it should! :)

How about source code? ;D
0

#4 User is offline   TheSteve

  • The Man from Japan
  • Icon
  • Group: Moderators
  • Posts: 1,813
  • Joined: 07-May 05
  • Location:Fukuoka, Japan
  • Interests:Computer Programming

Posted 25 September 2006 - 03:23 PM

View Postdavid_ES, on Sep 25 2006, 06:01 PM, said:

This file works in .NET?

Yes

View Postvikke, on Sep 25 2006, 09:59 PM, said:

How about source code? ;D

What do you need source code for? you can easily incorporate this in to any microsoft programming language. This includes C++. Use the #import compiler directive.

This post has been edited by TheSteve: 25 September 2006 - 03:23 PM

0

#5 User is offline   david_ES

  • Fanatic Fly
  • Icon
  • Group: Valued Members
  • Posts: 52
  • Joined: 20-July 05
  • Location:Canary Islands, Spain

Posted 25 September 2006 - 03:42 PM

Thanks, You could make the same with the API MessengerContentInstaller? it does not work to me adding it from the com objects: http://forums.fanati...showtopic=16972

Thanks
0

#6 User is offline   Dody

  • Liveā„¢ |) () |) '/
  • Icon
  • Group: Valued Members
  • Posts: 1,145
  • Joined: 26-October 04
  • Location:DK
  • Interests:Guitar, c++, Hacking, Religions, Debating...

Posted 25 September 2006 - 04:43 PM

sweet :D
excellent work Steve
0

#7 User is offline   twentytwo

  • I'm a new version
  • PipPipPip
  • Group: Members
  • Posts: 73
  • Joined: 05-April 06

Posted 26 September 2006 - 02:42 AM

Excellent work, I have a question though

I remember programming with the MSN Messenger library back in the old days and when you closed Messenger and then re-opened it the library would continue to function. But now with Windows Live Messenger, once Messenger is closed, the library stops functioning.

Is there any way around this?
0

#8 User is offline   TheSteve

  • The Man from Japan
  • Icon
  • Group: Moderators
  • Posts: 1,813
  • Joined: 07-May 05
  • Location:Fukuoka, Japan
  • Interests:Computer Programming

Posted 26 September 2006 - 10:43 AM

In C++ when you call a function after WLM has closed, the function will return 0x800706BA which is "The RPC server is unavailable."

In theory, when you get that result code, you can start a thread or a soft loop that will attempt to call OpenEvent() with the event name "MSNMSGR" If that returns something other than 0, either a new instance of messenger has been opened, or you caught it on the way out. In anycase, if you can be sure that it's a new instance, you can go ahead and create new objects.

If you decided to just create a new object anyways, it will work, but it will also restart messenger, which is probably not what the user wants.

This post has been edited by TheSteve: 26 September 2006 - 10:43 AM

0

#9 User is offline   twentytwo

  • I'm a new version
  • PipPipPip
  • Group: Members
  • Posts: 73
  • Joined: 05-April 06

Posted 05 October 2006 - 10:15 AM

Thanks for the response

I just tried using this file in .NET but I get an error message -

---------------------------
Microsoft Visual Basic 2005 Express Edition
---------------------------
A reference to 'MSNMessengerAPI.tlb' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
---------------------------
OK
---------------------------
0

#10 User is offline   david_ES

  • Fanatic Fly
  • Icon
  • Group: Valued Members
  • Posts: 52
  • Joined: 20-July 05
  • Location:Canary Islands, Spain

Posted 05 October 2006 - 04:42 PM

use this command to generate dll

tlbimp MSNMessengerAPI.tlb /out:MSNMessengerAPI.dll

tlbimp located in

F:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

next add the reference with the new dll
0

#11 User is offline   twentytwo

  • I'm a new version
  • PipPipPip
  • Group: Members
  • Posts: 73
  • Joined: 05-April 06

Posted 06 October 2006 - 01:05 AM

Thanks David :)

This works really well..

Without telling me the exact process, how did you make this Steve?
0

#12 User is offline   TheSteve

  • The Man from Japan
  • Icon
  • Group: Moderators
  • Posts: 1,813
  • Joined: 07-May 05
  • Location:Fukuoka, Japan
  • Interests:Computer Programming

Posted 07 October 2006 - 01:40 AM

I basically took the Windows Messenger version of the type library, researched all of the new class id/interfaces IDs and modified the original type library.
0

#13 User is offline   twentytwo

  • I'm a new version
  • PipPipPip
  • Group: Members
  • Posts: 73
  • Joined: 05-April 06

Posted 15 October 2006 - 03:01 AM

Edit: I'm having some weird .NET problems.. I'll get back to you

Edit 2:

Ok heres the deal, if you want your program to be able to discover new instances of the api when you close and reload Windows Live Messenger you should just have a timer that runs every 20 seconds or so and creates a new instance of the API, each time checking details such as FriendlyName, Status & Display Picture to see if there have been any changes since the last attempt to create an instance.

BUT

As I discovered today, there are some problems with this. When you close and reload messenger and your program attempts to create a new instance of the API you will receive some bogus COMException, and you won't receive it only once.. the error will be raised a number of times depending on how many events you have subscribed to in your application.

The solution to this is to NOT use the old style WithEvents method to handle the messenger API events, instead use the AddHandler/RemoveHandler functions to subscribe to the messenger events manually:

mMsgr = New MSNMessengerAPI.Messenger

			AddHandler mMsgr.OnMyStatusChange, New MSNMessengerAPI.DMSNMessengerEvents_OnMyStatusChangeEventHandler(AddressOf mMsgr_OnMyStatusChange)
			AddHandler mMsgr.OnMyPropertyChange, New MSNMessengerAPI.DMSNMessengerEvents_OnMyPropertyChangeEventHandler(AddressOf mMsgr_OnMyPropertyChange)


As bizarre as it sounds, if you do it this way you will not receive any bogus COMExceptions and your application can freely create new instances of the messenger API whenver it likes. Believe me.. it took me a looooong time to figure out this solution :)



Now I have one question/request for you TheSteve, would it be possible to modify this nice little library of yours so that it doesn't create new instances of WLM when you don't have WLM open? Some may like the standard functionality but because of polygamy, when I use this library in my application (which runs on windows startup) it has the tendancy to open a second instance of WLM... Which can be a pain in the ass because they both start signing in and one throws some weird "Display name could not be changed" error and then crashes.

Anyway all that aside, great job, your library fills a void which has been waiting to be filled for years :)

This post has been edited by twentytwo: 15 October 2006 - 10:56 AM

0

#14 User is offline   TheSteve

  • The Man from Japan
  • Icon
  • Group: Moderators
  • Posts: 1,813
  • Joined: 07-May 05
  • Location:Fukuoka, Japan
  • Interests:Computer Programming

Posted 19 October 2006 - 02:14 PM

View Posttwentytwo, on Oct 15 2006, 12:01 PM, said:

would it be possible to modify this nice little library of yours so that it doesn't create new instances of WLM when you don't have WLM open?

Unfortunately, in order for COM to get access to the interfaces, it MUST start the server. So as far as I am aware, there is no way to stop it from starting the server. It might be possible to some how specify that if the server isn't already running, you want it to fail, but I wouldn't know how to do that as I couldn't find anything about that in the documents.

View Posttwentytwo, on Oct 15 2006, 12:01 PM, said:

Some may like the standard functionality but because of polygamy, when I use this library in my application (which runs on windows startup) it has the tendancy to open a second instance of WLM... Which can be a pain in the ass because they both start signing in and one throws some weird "Display name could not be changed" error and then crashes.

Polygamy is an interesting story as far as Messenger API goes. The best way to get it to work with polygamy is to inject a dll in to messenger and get the API from there.
0

#15 User is offline   twentytwo

  • I'm a new version
  • PipPipPip
  • Group: Members
  • Posts: 73
  • Joined: 05-April 06

Posted 20 October 2006 - 05:05 AM

Ok thanks for the info, I'm working around the above problem by having a 30 second delay when my application starts with windows

Module Loader

	Public Sub Main()

		If Command() = "delay" Then
			Threading.Thread.Sleep(30000)
		End If

		Application.Run(MainForm)

	End Sub

End Module

0

#16 User is offline   CodeDude

  • I'm getting there
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 20-October 06

Post icon  Posted 20 October 2006 - 03:41 PM

Hi Steve
Great API!

Now I have this (C#):
MSNMessengerAPI.Messenger msn = new MSNMessengerAPI.Messenger();

1. Is it possible to change name/personal message/picture?
I only have succeed changing the "status".

2. How do I use "set_MyProperty" / "set_Property"?
(I assume these are the methods to use to change name/personal message/picture etc?

3. Is it possible to send chat-messeges etc, without opening a chat-window?

Kind Regards

This post has been edited by CodeDude: 20 October 2006 - 03:42 PM

0

#17 User is offline   vikke

  • Mr One Hundred
  • PipPipPipPip
  • Group: Members
  • Posts: 178
  • Joined: 07-September 05

Posted 20 October 2006 - 06:27 PM

1. I don't think you can with this API.
2. Used for changing DPs, set_MyProperty(5, DPURL);
3. You can open a chat via API, use ShowWindow API (or the .net way) to hide it. Then send keyevents or paste or use MSAA (Active Accessibility).

There are sereval articles about that in these forums

This post has been edited by vikke: 21 October 2006 - 07:37 AM

0

#18 User is offline   TheSteve

  • The Man from Japan
  • Icon
  • Group: Moderators
  • Posts: 1,813
  • Joined: 07-May 05
  • Location:Fukuoka, Japan
  • Interests:Computer Programming

Posted 21 October 2006 - 12:00 AM

1. Name and Personal Messages cannot be changed with this API. Picture can however:
msn.set_MyProperty(MSNMessenger.MCONTACTPROPERTY.MCONTACTPROP_USERTILE_PATH, "c:\\path\\to\\file\\image.png");


2. See #1

3. No, not with this API.
0

#19 User is offline   CodeDude

  • I'm getting there
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 20-October 06

Posted 21 October 2006 - 10:43 AM

View PostTheSteve, on Oct 21 2006, 01:00 AM, said:

1. Name and Personal Messages cannot be changed with this API. Picture can however:
msn.set_MyProperty(MSNMessenger.MCONTACTPROPERTY.MCONTACTPROP_USERTILE_PATH, "c:\\path\\to\\file\\image.png");


Ok, thanks. Works great.

But how about if I want to change Name or Personal Message?
What kind of solutions does it require?
Is this only possible with "hooking"?
0

#20 User is offline   vikke

  • Mr One Hundred
  • PipPipPipPip
  • Group: Members
  • Posts: 178
  • Joined: 07-September 05

Posted 21 October 2006 - 12:37 PM

The methods are:
1. Send a protocol message to the Messenger server.
2. Open Settings, use keyevents to type your name and click enter.
0

  • (10 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users