Shoutbox

Code needed for hiding sound alert! - 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: Code needed for hiding sound alert! (/showthread.php?tid=80014)

Code needed for hiding sound alert! by Jumpfreakske on 12-13-2007 at 05:36 PM

Hey everyone!
I'm making a new script again.
This is how it works: Everytime a contactperson types a message (word, sentence), then I automaticly send that message back, but with '/sound' in front of it.

I found that code already, so if someone types 'Nothing Else Matters',
then I send this back '/sound Nothing Else Matters' > and they here a sound.

But the problem is: When they say something wich I don't have a sound
of, then I get everytime this alert: 'Sound Isn't found....', and then
I must always klick OK.

What I'm asking is: Does someone know a code, to hide this alert.
> When somebody types 'Simplsons', that I don't get this
alert over and over again ?

Does somebody know this ?
Thanks...


RE: Code needed for hiding sound alert! by Jesus on 12-13-2007 at 06:47 PM

I haven't scripted anything for a while now, let alone visited the forum, but I think it should be possible to check the sound library for the existence of the sound before sending it.
Custom sounds can be found in:
C:\Documents and Settings\All Users\Application Data\Messenger Plus!\Custom Sounds\
and
C:\Documents and Settings\<Current User>\Application Data\Messenger Plus!\Custom Sounds\

At least, in WinXP. Vista will probably use a similar location, so I think something like %AppData%\Messenger Plus!\Custom Sounds (and %AllUsersProfile%\Application Data\Messenger Plus!\Custom Sounds) will be the best option.

The name of the sound as Plus! will display it can be found in Properties>Attributes (not sure about the names, I'm on a dutch machine), so you'll have to find a way to access this information.

Now I don't know if this method takes all possible scenarios into account (default sounds, sound packs, and the likes), but this is what first came on my mind.

Good Luck ;)


RE: RE: Code needed for hiding sound alert! by Jumpfreakske on 12-13-2007 at 07:32 PM

quote:
Originally posted by Jesus
I haven't scripted anything for a while now, let alone visited the forum, but I think it should be possible to check the sound library for the existence of the sound before sending it.
Custom sounds can be found in:
C:\Documents and Settings\All Users\Application Data\Messenger Plus!\Custom Sounds\
and
C:\Documents and Settings\<Current User>\Application Data\Messenger Plus!\Custom Sounds\

At least, in WinXP. Vista will probably use a similar location, so I think something like %AppData%\Messenger Plus!\Custom Sounds (and %AllUsersProfile%\Application Data\Messenger Plus!\Custom Sounds) will be the best option.

The name of the sound as Plus! will display it can be found in Properties>Attributes (not sure about the names, I'm on a dutch machine), so you'll have to find a way to access this information.

Now I don't know if this method takes all possible scenarios into account (default sounds, sound packs, and the likes), but this is what first came on my mind.

Good Luck ;)

Seems good, but now I need a code wo can make that possible.
Does anyone knows the code for that ?
RE: Code needed for hiding sound alert! by Matti on 12-13-2007 at 07:51 PM

Well, in theory you could store all sound IDs and names you can find in the .dat's in that folder, but this can take a lot of time of course. You could make it load the sounds into a global array on script start-up, which would have a structure like:

code:
var SoundsArray = new Array();
SoundsArray["Murray - Evil Laugh"] = "#4F004323E60";
SoundsArray["..."] = "#...";
And then, everytime you receive a message, you first check if the message is a sound name ("Murray - Evil Laugh") or a sound ID (#4F004323E60). In the first case, you'll have to send "/sound "+SoundArray[NAME], in the second case you can simply send the ID straight away: "/sound "+ID

But as I already said, the loading can take a long while when you have to do this every time the script starts. Maybe more interesting would be to have a command which loads the sounds and saves a text file or XML file with the sounds in it. Then, you can load that XML file instead at script start-up and thus you'd only need to load the sounds when you really ask for it. :P

I think I'll leave the rest to your inspiration and creativity. :)
RE: Code needed for hiding sound alert! by Jumpfreakske on 12-13-2007 at 08:08 PM

I'm now working with this kind of stuff to send my sounds:


code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
if(Message == "Veritas")
{
ChatWnd.SendMessage("/sound Veritas");
}
if(Message == "All For The Thrill")
{
ChatWnd.SendMessage("/sound All For The Thrill");
}

But if you have to do this for more than 300 Sounds,
Then it takes hours of copy/past/edit things....


I was thinking at a solution from this kind of genre:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
ChatWnd.Send("/sound" + Message);
}

And then for the alerthing.
RE: Code needed for hiding sound alert! by CookieRevised on 12-13-2007 at 09:05 PM

Forget about checking the files, XML, etc...

You should not check the files, instead you should check the registry for the sound names.

----

The files aren't saved with the name of the sound but with their ID, so if you check on the files you also need to process the contents of each sound and read out the MP3 id tags. This is waaaaay too much work and can take a long time, and it's a very very long way of doing things ;)

Simply check the registry. In this way, you also would be certain that you check the correct library, since a sound library can be private and it can be global. Also, you would only check the sounds of your current Messenger-account, not the account of someone else. And finally, the same for sounds which you have in your library but not physically on disc (anymore). Those wouldn't have been found if you just checked the files.

Bottom line:

1) First you need to check for the regisrty key SoundsPrivateDB in the user's registry settings:
HKEY_CURRENT_USER\Software\Patchou\Messenger Plus! Live\user's email\Preferences

If the DWORD value of this key is set to 1, then go to step 3

2) The user has a global/shared sound library. So you need to enumerate all the sounds found in:
HKEY_CURRENT_USER\Software\Patchou\Messenger Plus! Live\GlobalSettings\CustSounds

Proceed to step 4

3) The user has a private sound library. So you need to enumerate all the sounds found in:
HKEY_CURRENT_USER\Software\Patchou\Messenger Plus! Live\user's email\CustSounds

4) Enumerate all the sounds.

This means you need to read every subkey (You need to do this using the Windows registry APIs or using the WMI object type library (a bit easier), this can not be done using the standard or build-in methods).

The subkey's name is the ID of the sound.
Within this subkey you find a registry key named "Name".

It is this registry key which you need to read out and compare with the text you have recieved from your contacts.

Remember that just a part of the name is already enough for Plus! to find the sound. But it must be at least 2 characters long.

So if your contact has send "bingo" and you have a sound named "this is the bingo song", you would have a match. (The last match encountered will be played, unless there is somewhere a full match).

Eg: you have sounds with the names (encountered in this order in the registry (not the sound library window, that doesn't matter)):
"bongabonga song"
"Bingo"
"This is the bingo song"

If the user sends "bingo" then the sound named "Bingo" must be send by its ID. Because although it is part of the name of the last sound encountered, it is the full name of the second sound, and that takes priority.
If the user sends "song" then the sound named "This is the bingo song" must be send by its ID. Because it is the last sound which has bingo as part of its name.

Either use that method (sending sounds by ID), or... let the matching be done by Plus! itself and only check if the text recieved is somewhere in any of the "Name" keys of the sounds, if so, send the sound by using the /sound command and using the text recieved from the contact....



5) Determine if you found a match or not and execute the /sound command.... BUT, always first check if you can actually send something back to the chat window with ChatWnd::EditChangeAllowed. This is very often forgotten when using SendMessage, but it is very important.