Shoutbox

OnEvent_ChatWndEditKeyUp - 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: OnEvent_ChatWndEditKeyUp (/showthread.php?tid=88951)

OnEvent_ChatWndEditKeyUp by Ezra on 02-04-2009 at 12:58 PM

Is there any way this event could be created by scripting?

Also did anyone find out how to correctly catch the ENTER with OnEvent_ChatWndEditKeyDown with pure scripting?

I'm trying to detect how long the ENTER key was pressed and only let msn sent the message when it's being held for 5 seconds or so. Hope this is possible.


RE: OnEvent_ChatWndEditKeyUp by matty on 02-04-2009 at 01:22 PM

js code:
var oChatWnds = {};
/*Remarks

Because this event is fired for every single key pressed by the user, your event handler must return as fast as possible and not slow down the user.*/

function OnEvent_ChatWndEditKeyDown( pChatWnd, nKeyCode, bCtrl, bShift ) {
    if ( nKeyCode === 0xD /* VK_RETURN */ && bShift == false && bCtrl == false ) {
        oChatWnds[ pChatWnd.Handle ] = {};
            oChatWnds[ pChatWnd.Handle ].Counter = 0;
            oChatWnds[ pChatWnd.Handle ].pChatWnd = pChatWnd;
        MsgPlus.AddTimer( pChatWnd.Handle, 100 );
        return true;
    }
}

Once you detect this then you can activate a timer that checks GetAsyncKeyState to check if the Enter key is pressed. I would check every milisecond and stop the timer if it is not pressed.

js code:
function OnEvent_Timer( sTimerId ) {
    if ( Interop.Call( 'user32', 'GetAsyncKeyState', 0xD /* VK_RETURN */ ) !== 0 ) {
        oChatWnds[ sTimerId ].Counter++;
        MsgPlus.AddTimer( sTimerId, 100 );
    }
}