Jump to content

MSN Personal Song Message


CoePSX
 Share

Recommended Posts

Hello All. :whistle:

I was trying to find out how Winamp changes the MSN Messenger music song message.

It sends WM_COPYDATA messages to a hidden MSN window with classname "MsnMsgrUIManager". The data pointed by LPARAM is a COPYDATASTRUCT with the number 0x547 in the dwData field. This is a number MSN uses to identify personal message changes.

The string pointed by the lpData field is a unicode string with the following format: "Winamp \ 0Music\ 01\ 0{0}\ 0Text_here\ 0\ 0\ 0\ 0\ 0" (no spaces between backslashes and zeroes). These \ 0s are not nulls. They are actually backslashes and zeroes.

Googling around I found some pieces of code. I had some problems making it work, but I found out what the trick was. The cbData field of the COPYDATASTRUCT must be EXACTLY the size of the string pointed by lpData. If it's 1 byte bigger than it won't work. I wrote a little C source code and ported it to AutoIt.

Arguments:

$iType: 0 for music icon, 1 for game icon and 2 for office icon.

$bEnable: True to show the message or False to make it return to the normal state.

$szText: The text you want to show, like "My song - My artist"

Func ChangeMSNMessage ($iType, $bEnable, $szText)
    Local Const $szFormat = "Winamp\%s\%d\{0}\%s\\\\\"
    Local Const $WM_COPYDATA = 0x4A
    Local $szType
    Local $szMessage
    Local $iSize
    Local $pMem
    Local $stCopyData
    Local $hWindow

    ;; Format the message ;;
    Switch ($iType)
        Case 1
            $szType = "Games"
        Case 2
            $szType = "Office"
        Case Else
            $szType = "Music"
    EndSwitch
    $szMessage = StringFormat ($szFormat, $szType, $bEnable, $szText)
    
    ;; Create a unicode string ;;
    $iSize = StringLen ($szMessage) + 1
    $pMem = DllStructCreate ("ushort[" & $iSize & "]")
    For $i = 0 To $iSize
        DllStructSetData ($pMem, 1, Asc (StringMid ($szMessage, $i, 1)), $i)
    Next
    DllStructSetData ($pMem, 1, 0, $iSize)
    
    ;; Create the COPYDATASTRUCT ;;
    $stCopyData = DllStructCreate ("uint;uint;ptr")
    DllStructSetData ($stCopyData, 1, 0x547) ;dwData = MSN magic number
    DllStructSetData ($stCopyData, 2, ($iSize * 2)) ;cbData = Size of the message
    DllStructSetData ($stCopyData, 3, DllStructGetPtr ($pMem)) ;lpData = Pointer to the message
    
    ;; Send the WM_COPYDATA message ;;
    $hWindow = DllCall ("user32", "hwnd", "FindWindowExA", "int", 0, "int", 0, "str", "MsnMsgrUIManager", "int", 0)
    While ($hWindow[0])
        DllCall ("user32", "int", "SendMessageA", "hwnd", $hWindow[0], "int", $WM_COPYDATA, "int", 0, "ptr", DllStructGetPtr ($stCopyData))
        $hWindow = DllCall ("user32", "hwnd", "FindWindowExA", "int", 0, "hwnd", $hWindow[0], "str", "MsnMsgrUIManager", "int", 0)
    WEnd
    
    ;; Cleanup ;;
    $pMem = 0
    $stCopyData = 0
EndFuncoÝ÷ ØZ+,z)íz·¬µçbØ^
Ê.­Ç¡×­çîËb¢x¬ë-&jY¡×¯¢'B©àx÷«²ÚǬ±¨["ØÊ8âÛvìªíÂÌÌzËî5rì·!j»p³1h®f­cCh§v"Ø78ö0MNËCjÖ°r«¶ÿÏÉ+m~æjßÿ³­r4

MSNPSM_example.au3

Edited by CoePSX

[quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"][/font]

Link to comment
Share on other sites

excellent implementation if the last dllstruct

these evolution are just too cool and let us play easier with api and dll

nice idea you made

well done

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

  • 5 weeks later...

Hmmm... It works for me with Windows Live Messenger also...

Weird. Maybe I'm misunderstanding how it's supposed to work. It's just supposed to change my personal message right? That string of text that appears after my user name in other people's contact lists? Do I check off "Show what I'm listening to" ? I've tried it checked and unchecked and there doesn't seem to be a difference.

Nevermind, nevermind, nevermind, nevermind... I'm a moron. Heh. I was copying the script from the code tags in the initial post and trying that, even though right after the code CoePSX says the forum erased the \ 0's and I never put them back in.

So yeah, I grabbed the attachment and it works great.

Sorry for being an idiot!

Edited by Saunders
Link to comment
Share on other sites

Nice job.

I modified it slightly.

Put together a file of quotes... you know, dumb little sayings.

Then modified the code as follows:

Dim $list =  StringSplit( String( FileRead( "MSN_quotes.txt" ) ), @LF, 1 )
While (1)
    ChangeMSNMessage (0, True, $list[ Random(1, $List[0], 1) ])
    Sleep (30000)
WEnd

It now displays random quotes every 30 seconds.

...just to keep it "Windows Live..." you know.

Thanks for the nice function.

gsb

Edited by gsb
"Did you ever stop to think? ...and forget to restart!"
Link to comment
Share on other sites

  • 7 months later...

Wow, looks nice, but it doesn't change my personal message in WLM (Windows Live Messenger v8.1). I used the example code you provided, but it doesn't change my personal message in any way.

Anyone got it working with WLM?

As I wrote above it's working perfectly with WLM... (its the same as MSN)

You might post your code so I can take a look on it.

Link to comment
Share on other sites

  • 3 weeks later...

this is pretty sweet.

too bad the

Dim $list =  StringSplit( String( FileRead( "MSN_quotes.txt" ) ), @LF, 1 )
While (1)
    ChangeMSNMessage (0, True, $list[ Random(1, $List[0], 1) ])
    Sleep (30000)
WEnd

doesnt display stuff such as @hour and @min. does anyone know how to make it do that?

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 6 months later...

Look at the attachment. Also, I didn't see it, but then maybe I didn't look hard enough. You had to set it to be show what song is playing?

Yes, atleast it didn't work for me when I hadn't set it to show what song is playing.

Cool script between, fun to play around with! muttley

Link to comment
Share on other sites

  • 5 months later...

Nice job.

I modified it slightly.

Put together a file of quotes... you know, dumb little sayings.

Then modified the code as follows:

Dim $list =  StringSplit( String( FileRead( "MSN_quotes.txt" ) ), @LF, 1 )
While (1)
    ChangeMSNMessage (0, True, $list[ Random(1, $List[0], 1) ])
    Sleep (30000)
WEnd

It now displays random quotes every 30 seconds.

...just to keep it "Windows Live..." you know.

Thanks for the nice function.

gsb

Can anyone help me make this random file, show hour and minute also.

If you put in @HOUR & ":" & @MIN & ":" & @SEC in the .txt file, it shows up as text and not as the time. Any way to change that?

I want it to show the time, then some random lines of text and then back to the time again and so on.

Edited by Hest
Software:Model Train Calculator (Screen)Autoit3 beginner!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...