What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] Minimize to tray on focus contact window with a hotkey

[Request] Minimize to tray on focus contact window with a hotkey
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Request] Minimize to tray on focus contact window with a hotkey
js code:
function embedCode(hWnd){
    if(!subClassProcAddr){
        var hCurrentProcess = Interop.call("kernel32.dll", "GetCurrentProcess");
        subClassProcAddr = Interop.Call("kernel32.dll", "VirtualAlloc", null, CODE_SIZE, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
        var code = Interop.Allocate(CODE_SIZE);
        var pos = 0;
        code.SetAt(pos++, 0x55);                // push ebp
        code.SetAt(pos++, 0x8b);                // mov ebp, esp
        code.SetAt(pos++, 0xec);
        code.SetAt(pos++, 0x81);                // cmp dword ptr [ebp+12], WM_NCDESTROY
        code.SetAt(pos++, 0x7d);
        code.SetAt(pos++, 0x0c);
        code.SetAt(pos++, 0x82);
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x74);                // je remove
        code.SetAt(pos++, 0x31);
        code.SetAt(pos++, 0x81);                // cmp dword ptr [ebp+12], WM_CHAR
        code.SetAt(pos++, 0x7d);
        code.SetAt(pos++, 0x0c);
        code.SetAt(pos++, 0x02);
        code.SetAt(pos++, 0x01);
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x75);                // jne exit
        code.SetAt(pos++, 0x3a);
        code.SetAt(pos++, 0x83);                // cmp dword ptr [ebp+16], 23
        code.SetAt(pos++, 0x7d);
        code.SetAt(pos++, 0x10);
>>>        code.SetAt(pos++, 0x17);                /* Maybe 0x1B for the Escape key? */<<<
        code.SetAt(pos++, 0x75);                // jne exit
        code.SetAt(pos++, 0x34);
        code.SetAt(pos++, 0x6a);                    // push 0
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x6a);                    // push 0
        code.SetAt(pos++, 0x00);
        code.SetAt(pos++, 0x6a);                    // push WM_CLOSE
        code.SetAt(pos++, 0x10);
        code.SetAt(pos++, 0xff);                    // push [ebp+8]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x08);
        code.SetAt(pos++, 0xb9);                    // mov ecx, &GetParent
        code.WriteDWORD(pos, getLibraryProcAddress("user32.dll", "GetParent"));
        pos += 4;
        code.SetAt(pos++, 0xff);                    // call ecx
        code.SetAt(pos++, 0xd1);
        if(Messenger.Version >= 9){
            code.SetAt(pos++, 0x50);                // push eax
            code.SetAt(pos++, 0xb9);                // mov ecx, &GetParent
            code.WriteDWORD(pos, getLibraryProcAddress("user32.dll", "GetParent"));
            pos += 4;
            code.SetAt(pos++, 0xff);                // call ecx
            code.SetAt(pos++, 0xd1);
        }else if(Messenger.Version >= 8){
            code.WriteDWORD(pos, 0x00841f0f);        // nop dword ptr [eax + eax*1 + 00000000h]
            pos += 4;
            code.WriteDWORD(pos, 0x00000000);
            pos += 4;
        }       
        code.SetAt(pos++, 0x50);                    // push eax
        code.SetAt(pos++, 0xb9);                    // mov ecx, &PostMessageW
        code.WriteDWORD(pos, getLibraryProcAddress("user32.dll", "PostMessageW"));
        pos += 4;
        code.SetAt(pos++, 0xff);                    // call ecx
        code.SetAt(pos++, 0xd1);
        code.SetAt(pos++, 0xeb);                    // jmp exit
        code.SetAt(pos++, 0x12);
                                                // remove:
        code.SetAt(pos++, 0xff);                // push [ebp+24]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x18);
        code.SetAt(pos++, 0x68);                // push &subClassProcAddr
        code.WriteDWORD(pos, subClassProcAddr);
        pos += 4;
        code.SetAt(pos++, 0xff);                // push [ebp+8]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x08);
        code.SetAt(pos++, 0xb9);                // mov ecx, &RemoveWindowSubclass
        code.WriteDWORD(pos, getLibraryProcAddress("comctl32.dll", "RemoveWindowSubclass"));
        pos += 4;
        code.SetAt(pos++, 0xff);                    // call ecx
        code.SetAt(pos++, 0xd1);
                                                // exit:
        code.SetAt(pos++, 0xff);                // push [ebp+20]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x14);
        code.SetAt(pos++, 0xff);                // push [ebp+16]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x10);
        code.SetAt(pos++, 0xff);                // push [ebp+12]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x0c);
        code.SetAt(pos++, 0xff);                // push [ebp+8]
        code.SetAt(pos++, 0x75);
        code.SetAt(pos++, 0x08);
        code.SetAt(pos++, 0xb9);                // mov, ecx, &DefSubclassProc
        code.WriteDWORD(pos, getLibraryProcAddress("comctl32.dll", "DefSubclassProc"));
        pos += 4;
        code.SetAt(pos++, 0xff);                // call ecx
        code.SetAt(pos++, 0xd1);
        code.SetAt(pos++, 0xc9);                // leave
        code.SetAt(pos++, 0xc2);                // retn 24
        code.SetAt(pos++, 0x18);
        code.SetAt(pos++, 0x00);
       
        ASSERT(pos == CODE_SIZE, "Code insertion complete");
       
        Interop.Call("kernel32.dll", "WriteProcessMemory", hCurrentProcess, subClassProcAddr, code.DataPtr, CODE_SIZE, null);
    }
    if(subClassProcAddr){
        Interop.Call("comctl32.dll", "SetWindowSubclass", hWnd, subClassProcAddr, 0, 0);
    }
}

This post was edited on 05-20-2009 at 06:10 PM by matty.
05-20-2009 06:05 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Request] Minimize to tray on focus contact window with a hotkey - by warmth on 04-16-2007 at 10:41 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 04-17-2007 at 05:54 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 04-18-2007 at 03:10 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 04-18-2007 at 06:38 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 04-18-2007 at 08:14 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 04-19-2007 at 05:46 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 04-19-2007 at 10:17 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 04-20-2007 at 06:31 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 09-04-2008 at 08:26 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 09-05-2008 at 03:51 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 09-05-2008 at 04:23 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 01-13-2009 at 01:43 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 01-13-2009 at 02:11 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 01-13-2009 at 02:15 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 01-13-2009 at 03:38 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 01-13-2009 at 04:54 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 01-27-2009 at 12:10 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-14-2009 at 02:50 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-19-2009 at 02:22 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 05-19-2009 at 03:25 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-20-2009 at 02:21 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 05-20-2009 at 01:05 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-20-2009 at 05:00 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by Mnjul on 05-20-2009 at 05:09 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-20-2009 at 05:32 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 05-20-2009 at 05:33 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by Mnjul on 05-20-2009 at 05:38 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 05-20-2009 at 06:05 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-20-2009 at 08:14 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 05-20-2009 at 09:22 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-20-2009 at 11:32 PM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by matty on 05-21-2009 at 01:21 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 05-21-2009 at 03:03 AM
RE: [Request] Minimize to tray on focus contact window with a hotkey - by warmth on 11-14-2009 at 03:48 AM


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