Shoutbox

EXECUTE APPLICATION - 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: EXECUTE APPLICATION (/showthread.php?tid=61740)

EXECUTE APPLICATION by novolo on 06-27-2006 at 02:03 PM

Hi,  i would like to know how would be the script to execute an application when receiving a certain message from someone..

for example,  my WLM is always online,  and i could connect from another account far from home and run a certain application in my home just by sending for example:  !runNorton   !runWinamp   or whatever...

is it possible?


RE: EXECUTE APPLICATION by Jiggs on 06-27-2006 at 02:09 PM

cool, nice idea. but no idea here


RE: EXECUTE APPLICATION by The Brain on 06-27-2006 at 02:16 PM

For sure. Not too difficult either

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
        if(Message == "!runNotepad")
        {
                ChatWnd.SendMessage("/run c:\\windows\\notepad.exe");
        }
}


makes use of the MsgPlus "/run" command. Simply replicate the if statement for your programs you want to run.
RE: EXECUTE APPLICATION by Colin-uk on 06-27-2006 at 02:17 PM

i remember an old tool called "Arcine Messenger lite tools" did something similar for msn 4/5

but the developer stopped working on later versions :(

i loved that feature in the program

maybe research into that? :P


RE: EXECUTE APPLICATION by upsfeup on 06-27-2006 at 02:21 PM

I would suggest to add a "trusted" remote account or somekind of password access. Otherwise your friends could start to mess with your computer. You would arrive home and have 400 notepads opened! ;)


RE: EXECUTE APPLICATION by The Brain on 06-27-2006 at 02:32 PM

quote:
Originally posted by upsfeup
I would suggest to add a "trusted" remote account or somekind of password access. Otherwise your friends could start to mess with your computer. You would arrive home and have 400 notepads opened! ;)


Oh I agree completely! There is a lot of potential in the Plus Scripting engine for remotely controlling Messenger and the computer, but if not set up securely, it could be very bad. I just threw that together really quickly to illustrate that is could be done very simply.

Simple Security: Have your alternative account always have the same nickname. Check if(origin == "myOtherAccountsNick") before doing anything else. This is also quite insecure though, as anyone can change their nickname to whatever they want.

More secure would be getting the list of contacts in the ChatWnd, and checking that the specified contact is present & that the message came from their nickname. This would still be as insecure as the first option if you are in a group chat with your two accounts, but this is probably quite rare.

I don't plan on using this at all yet, I haven't come up with any cicumstances where it is useful to me. But it is certainly possible, and certainly could be useful.

And as far as passwords go - You probably don't want them sitting in a conversation window at your home computer all day, while you are at school or work.
RE: EXECUTE APPLICATION by novolo on 06-27-2006 at 03:11 PM

ok i made this code,    it verifies if its your "Remote Control" account by email...  and then runs the command

please tell me if this code is correct i haven't tried it

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
    if (Contact.Email == xxx@yyy.zzz) {
        if(Message == "!runNotepad"){
            ChatWnd.SendMessage("/run c:\\windows\\notepad.exe");
        }
    }
   
}

EDIT:  i now wanted to try it,  but a message pops up and says it cant run the script because it is defective or i don't have privileges to run scripts
RE: EXECUTE APPLICATION by The Brain on 06-27-2006 at 03:31 PM

No, that won't work. The variable "Contact" isn't defined. In this situation it isn't so simple to check who the message is from. The limitations are explained in the scripting documentation.

You will have to get the Contacts from the ChatWnd Object, and then go through each Contact object, and check if your "Remote Control" account is there, and then if the Name of your "Remote Control" is the same as "Origin".

I have to go to bed now. Hopefully someone else can help you if you have more questions.


RE: EXECUTE APPLICATION by novolo on 06-27-2006 at 03:38 PM

now?  does this work?

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
    var Contacts = ChatWnd.Contacts;
    var e = new Enumerator(Contacts);

    for(; !e.atEnd(); e.moveNext()){
        var Contact = e.item();
        if (Contact.Email == xxx@yyy.zzz) {
            if(Message == "!runNotepad"){
            ChatWnd.SendMessage("/run c:\\windows\\notepad.exe");
            }
        }
    }
   
   
}


RE: EXECUTE APPLICATION by Lou on 06-27-2006 at 03:59 PM

I suggest a simple login. You send !login <password> and if youre right, you can use the commands, if youre not right, you can't use them and therefore you can't do anything.


RE: EXECUTE APPLICATION by ShawnZ on 06-27-2006 at 03:59 PM

haha thats the worst way to run a program _ever_

var WSS = new ActiveXObject("WScript.Shell");
return WSS.Run("Appname");


RE: EXECUTE APPLICATION by Lou on 06-27-2006 at 04:02 PM

quote:
Originally posted by ShawnZ
haha thats the worst way to run a program _ever_

var WSS = new ActiveXObject("WScript.Shell");
return WSS.Run("Appname");
If you're so smart, write him one with a login to run notepad then, to show him how:P
RE: EXECUTE APPLICATION by ShawnZ on 06-27-2006 at 04:04 PM

steal someone elses code, i'm busy working on weblets :(


RE: EXECUTE APPLICATION by novolo on 06-27-2006 at 05:06 PM

ok, lets get back....

could anyone tell me why this code doesn't work?

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
var Contacts = ChatWnd.Contacts;
var e = new Enumerator(Contacts);

for(; !e.atEnd(); e.moveNext()){
var Contact = e.item();
if (Contact.Email == xxx@yyy.zzz) {
if(Message == "!runNotepad"){
ChatWnd.SendMessage("/run c:\\windows\\notepad.exe");
}
}
}


}

RE: RE: EXECUTE APPLICATION by Volv on 07-06-2006 at 12:52 AM

You're not setting an initial condition in your for() loop nor are you treating the email you are checking for as a string. You're also not actually checking if the user who sent you the message is xxx@yyy.zzz but if that user is within the conversation, this means that anyone in the conversation would be able to type !runNotepad (not just xxx@yyy.zzz) - I provided a little bit of extra protection by checking nicknames as well (although this still can be fooled). Also, I recommend putting the if() statement checking for a message outside the check-for-contact loop to reduce unnecessary processing every time a user sends you a message.
Try this;

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
    if(Message == "!runNotepad") {
        CheckAndRun('xxx@yyy.zzz', "/run c:\\windows\\notepad.exe", ChatWnd, Origin);
    }
}

function CheckAndRun(strEmail, strRun, ChatWnd, Origin) {
    var Contacts = ChatWnd.Contacts;

    for(var e = new Enumerator(Contacts); !e.atEnd(); e.moveNext()){
        var Contact = e.item();
        if (Contact.Email == 'xxx@yyy.zzz' && Origin == Contact.Name) {
            ChatWnd.SendMessage(strRun);
        }
    }
}

RE: EXECUTE APPLICATION by wlmcrap on 07-06-2006 at 03:37 AM

Hi,
Can someone please tell me how to fix my script so that it doesn't send the message to the contact, if you get what i mean.

Heres the Script:


function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
        if(Message == "!wmp")
        {
                ChatWnd.SendMessage("/run C:\\Program Files\\Windows Media Player\\wmplayer.exe");
        }
}

function OnEvent_Uninitialize(MessengerExit)
{
}


RE: RE: EXECUTE APPLICATION by Volv on 07-06-2006 at 06:10 AM

wlmcrap, reading the documentation can be useful - return the new value;

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
        if(Message == "!wmp")
        {
                ChatWnd.SendMessage("/run C:\\Program Files\\Windows Media Player\\wmplayer.exe");

                return '';
        }
}


RE: EXECUTE APPLICATION by wlmcrap on 07-06-2006 at 06:12 AM

sorry I thought that it would be something like that, but i'm new in javascript and i'm only in year 7.


Now it doesn't work at all with your changes to it.