Shoutbox

Script to run a command line whenever a contact becomes online - 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: Script to run a command line whenever a contact becomes online (/showthread.php?tid=75296)

Script to run a command line whenever a contact becomes online by jabaltie on 06-12-2007 at 06:29 PM

Hello !

I'd like to know if there would be out there some sort of script that would be "hooked" to the "Contact becomes online" event, so that I could run an external command line (generic) whenever a contact of my interest becomes on-line.

For instance, I wanna a script that whenever Mary becomes on-line, it launches (executes) a command line of my own.

What I would do on this command line ?

I would send a SMS to my mobile phone, so that wherever I am, I would RUN after a WLM machine in order to talk to Mary !

I'm fluent with programming languages, and with JavaScript as well. But I dont know WLM scripting yet...

Thanks in advance !

Hope the idea can help you out there ! See ya !


RE: Script to run a command line whenever a contact becomes online by Volv on 06-12-2007 at 06:37 PM

code:
function OnEvent_ContactSignin(strEmail) {
    new ActiveXObject("WScript.Shell").Run("\"C:\\path to file\\file.bat\"");
}
You can replace \"C:\\path to file\\file.bat\" with any console command.
RE: Script to run a command line whenever a contact becomes online by Matti on 06-12-2007 at 06:40 PM

Well, if you have any program which can send a message to your mobile, it's very easy to do that:

code:
function OnEvent_ContactSignin(Email) {
   if(Email == "mary@hotmail.com") {
      new ActiveXObject("WScript.Shell").Run('C:\sendsms.exe');
   }
}
or something likely... Note that if there are any spaces in your file path, you should place the path between quotes (e.g.: '"C:\Program Files\SendSMS\sendsms.exe"').

If you don't have a program which does that... well, I don't know. :P

EDIT: Damn, Volv beat me again. :( But he made an error: his code would execute for EVERY contact. :P
RE: Script to run a command line whenever a contact becomes online by Volv on 06-12-2007 at 06:42 PM

quote:
Originally posted by Mattike
But he made an error: his code would execute for EVERY contact. :P
I suppose :p

RE: Script to run a command line whenever a contact becomes online by jabaltie on 06-12-2007 at 07:49 PM

Thanks to you all folks for the help !

I just have to research now how to wrap that JavaScript code into a .plsc file....

Thanks !


RE: Script to run a command line whenever a contact becomes online by L. Coyote on 06-12-2007 at 07:54 PM

quote:
Originally posted by jabaltie
I just have to research now how to wrap that JavaScript code into a .plsc file....
Tips:

* Download the documentation (from the script database in MsgPlus! Live site).
* Search before posting something, as there's a chance it's been answered many times.

The PLSC file is simply a ZIP file renamed. All you need to do is zip your script, add a ScriptInfo.xml file, which is explained in the script documentation, change .zip for .plsc, and that's it. (Y)
RE: Script to run a command line whenever a contact becomes online by Volv on 06-13-2007 at 04:36 AM

quote:
Originally posted by jabaltie
Thanks to you all folks for the help !

I just have to research now how to wrap that JavaScript code into a .plsc file....

Thanks !
And you don't need to create a .plsc file in order to use a script. PLSC files are for the purpose of distributing the script to others.

Just go to the Script Preferences and click "Create new", then "Edit" and place the code in there, click "Save" and you're good to go.
RE: Script to run a command line whenever a contact becomes online by markee on 06-13-2007 at 04:50 AM

For running a program or opening a file or something similar use the code that has been said above.  ie

code:
...
new ActiveXObject("WScript.Shell").Run('C:\sendsms.exe');
...
But if you want to execute a command line then replace that line with something like this
code:
new ActiveXObject("WScript.Shell").Exec('shutdown -a');

That codes aborts a shutdown, i couldn't think of anything else off the top of my head and I know that one isn't harmful is you accidentally execute it.

I actually use the Exec method at uni in a HTML document to bypass the 15 minute timer they have on the 'express' computers :tongue:.
RE: Script to run a command line whenever a contact becomes online by jabaltie on 06-13-2007 at 01:37 PM

Well, it turns out that there must be some sort of security checking within scripts.

Cause my script CAN NOT be activated.

This is how I did the script :



function OnEvent_ContactSignin(Email)
  {
   if  ((Email == "jabaltie@unimep.br"))
       {
         new ActiveXObject("WScript.Shell").Run('C:\test\cl52\xtest391.exe ' + Email);
       }
  }


When I quote the line where the 'Run' command line is, the script CAN BE activated OK.

However, when I unquote that line, the script CAN NOT be activated anymore.

Any clues ?

I now doing this "run" is dangerous of course but, if only I could do it for THIS script...


Thanks again folks !


RE: Script to run a command line whenever a contact becomes online by jabaltie on 06-13-2007 at 01:44 PM

Ops, sorry, I found the mistake by myself...

It's the double slashes I should use on the RUN command line :

new ActiveXObject("WScript.Shell").Run('C:\\test\\cl52\\xtest391.exe ' + Email);


Now, one more thing.....

I like to edit my scripts using an external editor, which is TSE PRO 32 from SemWare. Wonderful editor.

So, would there be a way to do some sort of "# INCLUDE" within WLM Plus so that I could edit my scripts outside WLM itself ?

Say that inside WLM I simply would put

# INCLUDE "this_script_of_mine_on_this_file_path"

And then I could edit the script with my editor of choice ?


RE: Script to run a command line whenever a contact becomes online by Volv on 06-13-2007 at 02:28 PM

You really need to read the Scripting Documentation instead of being baby fed some of the most simplest things which can be done in/with scripts. If you can't find the scripting documentation, it is found here: http://www.msgpluslive.net/scripts/view/13-Official-Scripting-Documentation/

It is extremely easy to edit your code using an external editor.
EDIT: I'll give you a tip, you just open the script file(s) with the editor of your choice.


RE: Script to run a command line whenever a contact becomes online by jabaltie on 06-13-2007 at 02:57 PM

OK. I found it. Simply enable "debug" checking and you're done.

It works.

Sorry to bother the thread with my silly questions.

I have the docs already, but since I'm brazilian and right now I'm with my laptop on the beach, looking to all of those gorgeous girls, I find it easier to ask to the thread, instead of putting my eyes on the docs !

Just kidding. Thanks again. I SHALL not bother the thread anymore.

Bye.


RE: Script to run a command line whenever a contact becomes online by Volv on 06-13-2007 at 03:18 PM

quote:
Originally posted by jabaltie
but since I'm brazilian and right now I'm with my laptop on the beach, looking to all of those gorgeous girls, I find it easier to ask to the thread, instead of putting my eyes on the docs !
[Offtopic] Why do you need to be at the beach to look at gorgeous girls on your laptop? :p [/Offtopic]
RE: Script to run a command line whenever a contact becomes online by Jesus on 06-13-2007 at 05:04 PM

You can also try this script I created a while ago if your own version doesn't work out.


RE: Script to run a command line whenever a contact becomes online by Matti on 06-13-2007 at 07:25 PM

[OFFTOPIC]

quote:
Originally posted by markee
I actually use the Exec method at uni in a HTML document to bypass the 15 minute timer they have on the 'express' computers :tongue:.
Oh my god, that's great! :D It's wonderful to see how easy a system can be fooled. :)
[/OFFTOPIC]