What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [not really a release/help] my first script

[not really a release/help] my first script
Author: Message:
andrey
elite shoutboxer
****

Avatar

Posts: 795
Reputation: 48
– / Male / Flag
Joined: Aug 2004
O.P. Tongue  [not really a release/help] my first script
Yeah, this has been my first attempt evar at J(ava)script and programming in general..

And the result of five(:rolleyes:) days learning Jscript from scratch is: "auto-send ISI" :tongue:

The (pretty simple) idea was, that when I type a command in the conversation window, the script gets the Internal Sound Identifier for a Custom Sound (e.g. #CC506B2EDBC4) from the clipboard (if it's present) and sends the sound to the contact.
(might be useful when you're extremely lazy, browsing mpsounds.net and you want to send just one sound from a huge soundpack (the ISI is called Sound ID over there, btw))

Maybe that's not such a big thing, (not very useful either), but it's an achievement for me, and I'm pretty happy that I got it working :happy:

I'll post the code below, and ask you to comment on it (style, efficiency and so on)

Commands:
enable script: +isi
disable script: -isi
send sound: isi
code:
var enabled = false;
var ISI;


function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
   if(Message == "+isi") {
      enabled = true;
      return("");
   }
   if(Message == "-isi") {
      enabled = false;
      return("");
   }
   if(Message == "isi") {
         if(enabled == true)
            return(startISI());
   }
}


function startISI() {
   readClipboard();
   if(matchISI() == true) {
         return(Message = "/sound " + ISI);
      } else {
            return("");
      }
}


//http://shoutbox.menthix.net/showthread.php?tid=63067
function readClipboard() {
   var CF_TEXT = 1;
   var CF_OEMTEXT = 7;
   var CF_UNICODETEXT = 13;
   ISI = false;
   try {
      if(Interop.Call("User32", "OpenClipboard", 0)) {
         if(Interop.Call("User32", "IsClipboardFormatAvailable", CF_TEXT | CF_OEMTEXT)) {
            var hClipboardData = Interop.Call("User32", "GetClipboardData", CF_UNICODETEXT);
            var pchData = Interop.Call("Kernel32", "GlobalLock", hClipboardData);
            var size = Interop.Call("Kernel32", "GlobalSize", hClipboardData);
            var str = Interop.Allocate(size+2);
            Interop.Call("Kernel32", "RtlMoveMemory", str, pchData, size);
            ISI = str.ReadString(0);
            var unlocked = Interop.Call("Kernel32", "GlobalUnlock", hClipboardData);
         } else {
            Interop.Call("User32", "CloseClipboard");
            return(false);
         }
         Interop.Call("User32", "CloseClipboard");
      }
   } catch(exeption) {
      Interop.Call("User32", "CloseClipboard");
      return(false);
   }
   return(ISI);
}


function matchISI() {
   var re = /^\#[A-F0-9]{12}$/;
   var foundArray = re.test(ISI);
   if(foundArray == true) {
      return(true);
   } else {
      return(false);
   }
}

This post was edited on 07-17-2006 at 06:31 AM by andrey.
[Image: w2kzw8qp-sq2_dz_b_xmas.png]
07-17-2006 12:50 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[not really a release/help] my first script - by andrey on 07-17-2006 at 12:50 AM
RE: [not really a release/help] my first script - by Chestah on 07-17-2006 at 01:03 AM
RE: [not really a release/help] my first script - by RaceProUK on 07-17-2006 at 08:54 AM


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