Shoutbox

CTRL+C | CTRL+V - 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: CTRL+C | CTRL+V (/showthread.php?tid=73086)

CTRL+C | CTRL+V by DyLaK on 03-28-2007 at 12:41 PM

Hello, i want to use a bot which will talk with my contacts when im away. The bot is an aplication separate from messenger, and it works like this:

when I copy a sentence to the clipboard (ctrl+c), im saying that sentence to the bot, and he gives me an answer to the clipboard too, so if I paste it (ctrl+v), the answer will be shown.

what i want to do is to copy to the clipboard every message i recieve from a contact, (that action automatically will ask the bot) and then i want to paste from clipboard which the bot has answer (the bot automatically paste its answers to the clipboard).

I would be pleased if anyone could help me. Sorry for my english.


RE: CTRL+C | CTRL+V by Felu on 03-28-2007 at 02:43 PM

Have a look at [UPDATED] Clipboard Functions (that WORK) ;).


RE: CTRL+C | CTRL+V by CookieRevised on 03-28-2007 at 02:48 PM

Though, I would not recommend using copy/pasting at all for something like this (a communication between apps).

Copy/pasting is used in Windows everywhere, using it to communicate between apps will be troublesome, not reliable and may even interfear with normal copy/paste operations in Windows.

You better of using proper communication methods by sending application defined messages, using OLE, or even the extreme old DDE method, etc, which would still be 1000 times better (and way shorter to program) than using copy/pasting.


RE: RE: CTRL+C | CTRL+V by DyLaK on 03-28-2007 at 06:38 PM

quote:
Originally posted by Felu
Have a look at [UPDATED] Clipboard Functions (that WORK) ;).



thanks! i will have a look later to check if it works.

CookieRevised, i suppose thats not the best way to do that, but what you say is very difficult to do for me, so if the the copy/pasting works fine while im awat from keyboard, its ok.


EDIT: i have tried the code, and it works, but not at all. I think its using a lot the clipboard so after a few messages i cant access to it. I think that maybe if I use a delay it will work fine. My code is something like this:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, User, Message, Kind) {
    if (botActive[ChatWnd.Handle] == true) {
        if (Kind == 1 && User != Messenger.MyName) {
            var m = Message.toLowerCase();
            writeClipboard(m);
            var mbot = readClipboard();
            mbot = mbot.toLowerCase();
            while((m == mbot) || (mbot = false)){
                mbot = readClipboard();
                mbot = mbot.toLowerCase();
            }
            ChatWnd.SendMessage(readClipboard());
            contador = contador + 1;
            if(contador == 5){
                clearClipboard();
                contador = 0;
            }
        }   
    }
}

how can i improve it?


RE: RE: RE: CTRL+C | CTRL+V by CookieRevised on 03-28-2007 at 11:48 PM

quote:
Originally posted by DyLaK
CookieRevised, i suppose thats not the best way to do that, but what you say is very difficult to do for me.
Using copy/pasting is a hell more difficult to properly program than using any other method.

quote:
Originally posted by DyLaK
code:
(...)
how can i improve it?
Quit frankly: don't and use the methods I suggested. Using copy/paste is never going to work properly.
RE: CTRL+C | CTRL+V by DyLaK on 03-29-2007 at 12:25 AM

finally i fixed it with a delay function. messenger freezes during that delay, but i only want it when im away, so it works perfect for me :)

here is the code:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, User, Message, Kind) {
    if (botActive[ChatWnd.Handle] == true) {
        if (Kind == 1 && User != Messenger.MyName) {
            var m = Message.toLowerCase();
            writeClipboard(m);
            pause(500);
            var mbot = readClipboard();
            mbot = mbot.toLowerCase();
            ChatWnd.SendMessage(mbot);
            clearClipboard();
        }
    }
}

function pause(milisegundos){
    var date = new Date();
    var curDate = null;
    do{
        curDate = new Date();
    } while (curDate - date < milisegundos);
}