Newbie Help - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Newbie Help (/showthread.php?tid=77150)
Newbie Help by ArkaneArkade on 09-01-2007 at 02:06 AM
Hey guys, I'm looking for a little help witha couple of minor issues I've been having. I think they're really easy to sort, but then again I've been unable to sort them so...
The first is with arrays. I've not used them since uni 3 years ago, so I'm not entirely sure how to do it. I have a script that needs to act upon recieving a message from a contact, but only on the first message, similar to the MSN popups, so I've made it work by adding names to an array as I recieve messages from them. This has worked to stop the function being triggered multiple times, but I dont know how to remove them from the array so they dont trigger again after the window has been closed. Can anyone tell me how to delete an entry from an array?
The second is with a media script I've made. It's meant to get media information froma network server, and make that into my PSM, however because of the way it's working it sometimes screws up and changes teh actual PSM to be the media info, so it still displays after the media has stopped. I'd like to know if theres a way to change the actual messenger media variable with Plus, instead of the PSM, to make this issue go away... or if there is any other method which may solve the problem.
Cheers all
RE: Newbie Help by roflmao456 on 09-01-2007 at 03:06 AM
i could help with number 1.
use the "splice" method/thingy (whatever you call it)
look on W3cschools.
code: //used in WLMini Media Player
PLS.splice(0,1); // deletes PLS[0]
RE: Newbie Help by ArkaneArkade on 09-01-2007 at 03:35 AM
OK, cheers mate. I figured out some more of my prolem too now. I was using a friends reccommendation to make the array numbered, but now I'm changing that to just use the contacts email for the array cell, and setting the data as 1. Hopefully it will make thing much, much simpler, without the need to search trhough various loops. Thanks again mate.
RE: Newbie Help by Matti on 09-01-2007 at 07:31 AM
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);
}
RE: Newbie Help by ArkaneArkade on 09-02-2007 at 02:08 AM
Thats perfect mate. I'll give it a try, and maybe all my problems will be solved. I got the first script working perfectly now, and there wont be any issues as long as the ChatWnd handle is unique to each chat.
Thanks for all the help guys
StevieD WEll, it took me a while, but I got the setNowPlaying function working. Now all the scripts are going just how I want them, so thanks to all for the help.
Many cheers to -dt- as well for his code. Worked perfectly.
|