It's really useful
, but when your script is initialized for first time an error is shown in the
Scripting Debugging window and sometimes, one of the applications suddenly crashed ending with a #51 error.
code:
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Error: Raíz no válida en la clave del registro "HKCU\SOFTWARE\Patchou\Messenger Plus! Live\GlobalSettings\Scripts\CViewer\Settings\Last_Text". (code: -2147024894)
File: CViewer.js. Line: 86.
Function OnEvent_Initialize returned an error. Code: -2147352567
I've just taken a look at the source and made some changes for personal usage.
code:
var WM_DRAWCLIPBOARD = 0x308;
var CF_TEXT = 1;
var CF_OEMTEXT = 7;
var CF_UNICODETEXT = 13;
function OnEvent_Initialize(){
wnd = MsgPlus.CreateWnd('Interface.xml', 'WndHistory');
wnd.RegisterMessageNotification(WM_DRAWCLIPBOARD);
Interop.Call('user32', 'SetClipboardViewer', wnd.Handle);
MakeWndTransparent(wnd.Handle, trans);
}
function OnWndHistoryEvent_MessageNotification(PlusWnd, Message, wParam, lParam){
switch (Message) {
case WM_DRAWCLIPBOARD:
Interop.Call('user32', 'OpenClipboard', PlusWnd.Handle);
if (Interop.Call('user32', 'IsClipboardFormatAvailable', CF_TEXT | CF_OEMTEXT ))
{
var handle= Interop.Call('user32', 'GetClipboardData', CF_UNICODETEXT);
var size = Interop.Call('kernel32', 'GlobalSize', handle);
var str = Interop.Allocate(2 * (size + 1));
Interop.Call('kernel32', 'RtlMoveMemory', str, handle, size);
PlusWnd.LstView_AddItem('history', str.ReadString(0));
str.Size=0;
}
Interop.Call('user32', 'CloseClipboard');
break;
}
}
so you won't need to use any timer, or read/write data from/into the windows registry... anymore