Script to run a command line whenever a contact becomes online |
Author: |
Message: |
jabaltie
New Member
Posts: 7
Joined: Jun 2007
|
O.P. Script to run a command line whenever a contact becomes online
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 !
|
|
06-12-2007 06:29 PM |
|
|
Volv
Skinning Contest Winner
Posts: 1233 Reputation: 31
35 / /
Joined: Oct 2004
|
RE: Script to run a command line whenever a contact becomes online
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.
This post was edited on 06-12-2007 at 06:38 PM by Volv.
|
|
06-12-2007 06:37 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: Script to run a command line whenever a contact becomes online
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.
EDIT: Damn, Volv beat me again. But he made an error: his code would execute for EVERY contact.
This post was edited on 06-12-2007 at 06:40 PM by Matti.
|
|
06-12-2007 06:40 PM |
|
|
Volv
Skinning Contest Winner
Posts: 1233 Reputation: 31
35 / /
Joined: Oct 2004
|
RE: Script to run a command line whenever a contact becomes online
quote: Originally posted by Mattike
But he made an error: his code would execute for EVERY contact.
I suppose
|
|
06-12-2007 06:42 PM |
|
|
jabaltie
New Member
Posts: 7
Joined: Jun 2007
|
O.P. RE: Script to run a command line whenever a contact becomes online
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 !
|
|
06-12-2007 07:49 PM |
|
|
L. Coyote
Senior Member
Captain Obvious
Posts: 981 Reputation: 49
39 / /
Joined: Aug 2004
Status: Away
|
RE: Script to run a command line whenever a contact becomes online
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.
Hack, hack, hack!
Finally became a Systems Analyst!
|
|
06-12-2007 07:54 PM |
|
|
Volv
Skinning Contest Winner
Posts: 1233 Reputation: 31
35 / /
Joined: Oct 2004
|
RE: Script to run a command line whenever a contact becomes online
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.
|
|
06-13-2007 04:36 AM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: Script to run a command line whenever a contact becomes online
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 .
|
|
06-13-2007 04:50 AM |
|
|
jabaltie
New Member
Posts: 7
Joined: Jun 2007
|
O.P. RE: Script to run a command line whenever a contact becomes online
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 !
|
|
06-13-2007 01:37 PM |
|
|
jabaltie
New Member
Posts: 7
Joined: Jun 2007
|
O.P. RE: Script to run a command line whenever a contact becomes online
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 ?
|
|
06-13-2007 01:44 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|