[OFF TOPIC]
Originally edited in in previous post, but didn't saw you already replied, so:
EDIT & PS: don't get me wrong, I'm not entirly 100% behind what I've said
here in my previous post myself... but it is a tricky subject, and my initial reaction was probably because of the way you replied to his script like he did something seriously bad while you didn't included anything new or different in that code compared to the original code shown on MSNFanatic (eg: like checking for string length, polygamy issue, etc), it is not even optimized or whatever, just a copy in itself.
quote:
Originally posted by -dt-
yes but the fact is he didnt do it himself
that's very true too...
[/OFF TOPIC]
quote:
Originally posted by -dt-
i personally dont agree with sending it only to the current process, but heh i dont use polygamy but checking if the string is too long is a good idea though
The reason for the need for polygamy compatibility is because such scripts as this might be configured differently according to who is logged in. If you don't include this, and one uses polygamy the script will even send the string multiple times to all messengers because of the way scripts are run in Plus!, which is useless...
Anyways, I would do it like this when I just
copy the original code (so no double unneeded checks):
code:
// Sends to all running messengers
var hMSGRUI = 0;
while (hMSGRUI = Interop.Call('User32', 'FindWindowExW', 0, hMSGRUI, 'MsnMsgrUIManager', 0))
Interop.Call('User32', 'SendMessageW', hMSGRUI, WM_COPYDATA, 0, copyDataStruct);
And my recommended implementation:
code:
// Sends only to our own messenger
var tIDCurrent = Interop.Call('Kernel32', 'GetCurrentThreadId');
var hMSGRUI = 0;
while (hMSGRUI = Interop.Call('User32', 'FindWindowExW', 0, hMSGRUI, 'MsnMsgrUIManager', 0))
if (Interop.Call('User32', 'GetWindowThreadProcessId', hMSGRUI, 0) === tIDCurrent)
Interop.Call('User32', 'SendMessageW', hMSGRUI, WM_COPYDATA, 0, copyDataStruct);
To make sure the string isn't too long, to avoid errors:
code:
song.WriteString(0, ('\\0' + type + '\\0' + Math.abs(enabled) + '\\0' + format + '\\0' + title + '\\0' + artist + '\\0' + album + '\\0' + contentID).substr(0, 253) + '\\0');