What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011

[Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011
Cookie couldn't you do something along these lines?

Javascript code:
// Registry key locations  
var HKEY_CURRENT_USER = 0x80000001;
var HKCU = HKEY_CURRENT_USER;
var HKEY_LOCAL_MACHINE = 0x80000002;
 
// Registry key constants
var ERROR_SUCCESS = 0;
var KEY_ALL_ACCESS = 0xf003f;
 
// Registry Notify Filters
var REG_NOTIFY_CHANGE_LAST_SET = 0x4;
 
// Script variables
var MAX = 255;
var RegHandle;
var INFINITE = 0xFFFFFFFF;
var WAIT_FAILED = 0xFFFFFFFF;
 
function Registry_OpenKey(HKEY, lpSubKey, samDesired) {
    if (typeof samDesired === 'undefined') samDesired = KEY_ALL_ACCESS;
    var h = Interop.Allocate(4);
    Interop.Call('advapi32', 'RegOpenKeyExW', HKEY, lpSubKey, 0, samDesired, h);
    return h.ReadDWORD(0);
}
 
function Registry_CloseKey(HKEY) {
    return Interop.Call('advapi32', 'RegCloseKey', HKEY) === ERROR_SUCCESS;
}
 
function OnEvent_Initialize() {
    if (Messenger.MyStatus < STATUS_INVISIBLE) return false;
    MonitorRegistry(HKCU, 'Software\\Microsoft\\MSNMessenger\\PerPassportSettings\\' +  Messenger.MyUserID, true);
}
 
function OnEvent_SigninReady() {
    OnEvent_Initialize();
}
 
function OnEvent_Uninitialize() {
    Registry_CloseKey(RegHandle);
}
 
function MonitorRegistry(HKEY, lpSubKey, bContinueMonitoring) {
    RegHandle = Registry_OpenKey(HKEY, lpSubKey);
   
    var SECURITY_ATTRIBUTES = Interop.Allocate(12);
        SECURITY_ATTRIBUTES.WriteDWORD(0, 12);
       
    var lpszName = Interop.Allocate(2*MAX+2);
        lpszName.WriteString(0, 'MonitorRegistry');
    var lpName = Interop.Allocate(4);
        lpName.WriteDWORD(0, lpszName.DataPtr);
       
    var hEvent = Interop.Call('kernel32', 'CreateEventW', SECURITY_ATTRIBUTES.DataPtr, true, false, lpName.DataPtr);
   
    var retVal = Interop.Call('advapi32', 'RegNotifyChangeKeyValue', RegHandle, false, REG_NOTIFY_CHANGE_LAST_SET, hEvent, false);
   
    if (retVal === ERROR_SUCCESS) {
        if (Interop.Call('kernel32', 'WaitForSingleObject', hEvent, INFINITE) === WAIT_FAILED) {
            // WAIT_FAILED, NO CHANGE OCCURED
        } else {
            // CHANGE OCCURED
            // READ ShowConvWndTabs
           
            Registry_CloseKey(RegHandle);
            Interop.Call('kernel32', 'CloseHandle', hEvent);
            if (bContinueMonitoring) {
                MonitorRegistry(HKEY, lpSubKey, bContinueMonitoring);
            }
        }
    }
}


By the looks of things doing this will crash WLM as WaitForSingleObject is a synchronous call. You would have to externalize it.

This post was edited on 03-25-2011 at 02:05 PM by matty.
03-25-2011 01:50 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 03:33 PM
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by matty on 03-24-2011 at 04:52 PM
RE: RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 05:02 PM
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by matty on 03-24-2011 at 05:06 PM
RE: RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 07:28 PM
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by matty on 03-24-2011 at 08:33 PM
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 09:56 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by matty on 03-24-2011 at 10:31 PM
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Matti on 03-24-2011 at 10:37 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 10:53 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by CookieRevised on 03-24-2011 at 10:56 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Matti on 03-24-2011 at 11:08 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 11:10 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by matty on 03-24-2011 at 11:17 PM
RE: RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 11:27 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by CookieRevised on 03-24-2011 at 11:26 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by CookieRevised on 03-24-2011 at 11:33 PM
RE: RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 11:38 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by CookieRevised on 03-24-2011 at 11:41 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Domsy on 03-24-2011 at 11:46 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by matty on 03-25-2011 at 01:50 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by CookieRevised on 03-25-2011 at 03:50 PM
RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - by Matti on 03-25-2011 at 07:24 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On