Shoutbox

Email PM Script - 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: Email PM Script (/showthread.php?tid=77112)

Email PM Script by Chunk1993 on 08-30-2007 at 11:44 AM

Is there  [ or is it possible ] a script that shows how many emails you have in your personal message??


RE: Email PM Script by Spunky on 09-10-2007 at 12:15 PM

The registry function was written by Matty. The script just gets the number of emails from the registry key windows uses to display the number of emails on the welcome screen.

code:
var email = your@email.com;

function OnEvent_Timer(timer){
    Messenger.MyPersonalMessage = GetKeyValue(0x80000001,"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"+email,"MessageCount");
MsgPlus.AddTimer("myTimer",120000);
}

function OnEvent_Initialize(){
    MsgPlus.AddTimer("myTimer",1000);
}

var KEY_READ = 0x20019;
var KEY_WRITE = 0x20006;
var KEY_EXECUTE = 0x20019;
var KEY_ALL_ACCESS = 0xf003f;
var REG_OPTION_NON_VOLATILE = 0;
var ERROR_SUCCESS = 0;
var ERROR_NO_MORE_ITEMS = 259;
function Registry_GetKeyValue(lKeyLocation, sKey, sKeyName) {
    var hKey = Interop.Allocate(4);
    var buff_size = 255;
    var lBufferSize = Interop.Allocate(4);
    lBufferSize.WriteDWORD(0, 2 * buff_size);
    var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_READ, hKey);
    if (lRetVal === ERROR_SUCCESS) {
        var lpType = Interop.Allocate(4);
        lRetVal = Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, 0, lBufferSize);
        if (lRetVal === ERROR_SUCCESS) {
            switch (lpType.ReadDWORD(0)) {
                case REG_EXPAND_SZ :
                case REG_MULTI_SZ :
                case REG_SZ :
                    var Buffer = Interop.Allocate(2 * (lBufferSize.ReadDWORD(0) + 2));
                    Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, Buffer, lBufferSize);
                    Buffer = Buffer.ReadString(0);
                    break;
                case REG_DWORD:
                    var Buffer = Interop.Allocate(Math.max(4, lBufferSize.ReadDWORD(0)));
                    Interop.Call('Advapi32', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, Buffer, lBufferSize);
                    Buffer = Buffer.ReadDWORD(0);
                    break;
                case REG_BINARY :
                    var Buffer = Interop.Allocate((lBufferSize.ReadDWORD(0)+1)*2);
                    Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, Buffer, lBufferSize);
                    Buffer = Buffer.ReadString(0);
                    break;
                default: return false; //Cannot read registry key
            }
            Registry_CloseKey(hKey.ReadDWORD(0));
            return Buffer;
        } else { return false; }
    } else { return false; }
}