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 );
}
}