Matti
Elite Member
    

Script Developer and Helper
Posts: 1646 Reputation: 39
32 / / 
Joined: Apr 2004
|
RE: Newbie Help
As for your second problem, you can request the current media with Messenger.MyMedia. However, you can't set it using that method. Therefore, you'll need an extra function which sends a message to Messenger, telling it to change the media.
All credits for this one go to -dt-!
code: //Modifies the current media, thanks to -dt-!
/* Parameters:
enabled (Boolean) - Sets whether to enable or disable the media.
type (String) [opt] - The icon to display, can be "Music", "Games" or "Office"
format (String) [opt] - Format used for the media message. Can contain {0} for title, {1} for artist, etc. but can also be a simple message
title (String) [opt] - Title, replaced in format by {0}
artist (String) [opt] - Artist, replaced in format by {1}
album (String) [opt] - Album name, replaced in format by {2}
contentID (String) [opt] - Content ID, replaced in format by {3}
*/
/* Examples:
setNowPlaying(true, "Music", "Me - My crappy song") - Displays a music message.
setNowPlaying(true, "Music", "{1} - {0}", "My crappy song", "Me") - Same as above, but by using title and artist fields.
setNowPlaying(false) - Turns off the media message, Messenger will display your PSM.
*/
function setNowPlaying(enabled, type, format, title, artist, album, contentID) {
//Set empty variables
if(typeof(type) == "undefined")type = "Music";
if(typeof(format) == "undefined")format = "";
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;
//Reference
var song = Interop.Allocate(512);
//Create the Media string
song.WriteString(0, "\\0" + type + "\\0" + enabled + "\\0" + format +"\\0" + title +"\\0" + artist + "\\0" + album + "\\0" + contentID + "\\0");
//Write our copyDataStruct Structure
var copyDataStruct = Interop.Allocate(12);
copyDataStruct.WriteDWORD(0, 0x547); //dwData
copyDataStruct.WriteDWORD(4, song.Size); //cbData
copyDataStruct.WriteDWORD(8, song.DataPtr); //lpData
//Send it to all open messengers
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);
}
|
|