What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How To Display The Time in Media Message?

How To Display The Time in Media Message?
Author: Message:
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: How To Display The Time in Media Message?
There is a function that allows one to change their media mesage.

Okay, you want to have the time in your media message. What you should do, is create a Date object like this:

code:
var CurDateTime = new Date();

Then you can retrieve a time string using toLocaleTimeString() like this:

code:
var Time = CurDateTime.toLocaleTimeString();

Then you should pass the Time variable to the function below.

code:
/*

function SetNowPlaying([boolean] enabled: specifies whether to enable the message or not,
[string] type: the type of message, can be Music, Games, Office,
[string] format: the format, see below,
[string] title: title of the 'song',
[string] artist: artist of the 'song',
[string] album: album of the 'song',
[string] contentID: content ID of the 'song', can be anything);
ALL PARAMETERS OPTIONAL


FORMAT DESCRIPTION

The format is defined by 4 numbers: 0, 1, 2 and 3. These represent respectively Title, Artist, Album, ContentID. Enclose the numbers in { these brackets }. Valid format would be:

{3}: {0} - {1} (on "{2}")

This would result in:

<CONTENTID>: Proud mary - John Fogerty (on "The long road home")

Experiment with this.

*/
// Function by -dt-, modified slightly by myself
function SetNowPlaying(enabled, type, format, title, artist, album, contentID){
    if(typeof(type) == "undefined")type = "Music";
    if(typeof(format) == "undefined")format = "{0}";
    if(typeof(title) == "undefined")title = "";
    if(typeof(artist) == "undefined")artist = "";
    if(typeof(album) == "undefined")album = "";
    if(typeof(contentID) == "undefined")contentID = "";
    enabled = Math.abs(enabled);
    var WM_COPYDATA = 0x4A;
    var MediaMessage = "FMD\\0" + type + "\\0" + enabled + "\\0" + format +"\\0" + title +"\\0" + artist + "\\0" + album + "\\0" + contentID + "\\0";
    var song = Interop.Allocate((MediaMessage.length + 1) * 2);
    song.WriteString(0, MediaMessage);
    var copyDataStruct = Interop.Allocate(12);
    copyDataStruct.WriteDWORD(0, 0x547); //dwData
    copyDataStruct.WriteDWORD(4, song.Size); //cbData
    copyDataStruct.WriteDWORD(8, song.DataPtr);  //lpData
    var hMSGRUI = 0;
    do{
        hMSGRUI = Interop.Call("User32", "FindWindowExW", 0, hMSGRUI, "MsnMsgrUIManager", 0);
        if(hMSGRUI > 0){
            Interop.Call("User32", "SendMessageW", hMSGRUI, WM_COPYDATA, 0, copyDataStruct);   
        }
    }while(hMSGRUI != 0);
    var listeningtoshouldbe = Messenger.MyCurrentMedia;
}


For further explanation about JScript, the scripting language of Plus!, please refer to Microsoft's JScrit user's guide and JScript language reference.

Furthermore, you may want to update your media message every once in a while. To do so, you need timers. You can use the following code to add a timer to your script:

code:
MsgPlus.AddTimer("TmrUpdateMedia",120000 /* 2 minutes is 120 seconds, is 120,000 milliseconds */);

Please refer to the scripting documentation about timers. Every time OnEvent_Timer() is called by Plus!, you need to add the same timer again.

This post was edited on 01-03-2009 at 08:47 PM by SmokingCookie.
01-03-2009 08:39 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
How To Display The Time in Media Message? - by ainain on 01-03-2009 at 06:29 PM
RE: How To Display The Time in Media Message? - by Chris4 on 01-03-2009 at 06:36 PM
RE: How To Display The Time in Media Message? - by ainain on 01-03-2009 at 06:48 PM
RE: How To Display The Time in Media Message? - by SmokingCookie on 01-03-2009 at 08:39 PM
RE: How To Display The Time in Media Message? - by Spunky on 01-03-2009 at 08:41 PM
RE: How To Display The Time in Media Message? - by SmokingCookie on 01-03-2009 at 08:43 PM
RE: How To Display The Time in Media Message? - by ainain on 01-04-2009 at 08:36 AM
RE: How To Display The Time in Media Message? - by SmokingCookie on 01-04-2009 at 09:01 AM
RE: RE: How To Display The Time in Media Message? - by ainain on 01-05-2009 at 01:57 PM
RE: How To Display The Time in Media Message? - by SmokingCookie on 01-05-2009 at 06:00 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On