What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!)

[Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!)
Author: Message:
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
O.P. [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!)
Subclassing is quite a useful way of monitoring the messages sent to the keyboard (such as key presses), mouse (such as right mouse clicks) and windows (such as minimizing).

Plus! can already do some subclassing; take for example matty's hotkey code and SpunkyLoveMuff's StatusKey script. These both involve an invisible Plus! window which monitors the keyboard for a specific hotkey.

However, sometimes Plus! windows are not enough. For example, (as far as I know) it is impossible to detect the changing of tabbed chats using only the Plus! scripting engine and the Win32 API. It is even more impossible to detect messages sent to external applications (like Winamp for example).

This is where the ActiveXObjects come in. By using these, we are able to do all these things, right in Plus! itself!

After doing some browsing, I came across two free subclassing ActiveX files.


1. ARSubclass

Link
Download

ARSubclass is a very lightweight ActiveX library. It allows you to monitor the messages sent to a specific window (given its handle). Firstly, the DLL is required to be registered when the script is imported, so this line must be added to ScriptInfo.xml:
code:
<OleFiles>
    <FileName>ARSubclass.dll</FileName>
</OleFiles>
Here is an example code of how to use it:
code:
var ARSubclass = new ActiveXObject("ARSubclassLib.ARSubclass");

function OnEvent_Initialize(MessengerStart) {
    ARSubclass.hWnd = Messenger.ContactListWndHandle;
    ARSubclass.Message(/* WM_ACTIVATE */ 6) = true;
}

function OnEvent_ContactListWndCreated() { OnEvent_Initialize(); }

var Event = function() {
    function ARSubclass::WindowProc(hWnd, iMessage, wParam, lParam, Res) {
        if(wParam === /* WA_INACTIVE */ 0) Debug.Trace("WA_INACTIVE");
        if(wParam === /* WA_ACTIVE */ 1) Debug.Trace("WA_ACTIVE");
        if(wParam === /* WA_CLICKACTIVE */ 2) Debug.Trace("WA_CLICKACTIVE");
    }
}

Event();
This will trace when the WM_ACTIVATE message is sent to the contact list and show whether it is activated, activated by click or deactivated. (Here, "activated" simply means that the window gets "focus".) When the contact list is created, the ActiveXObject takes its handle and is set to receive all WM_ACTIVATE messages. When it receives one of these messages, it is processed by the WindowProc function with wParam and lParam. (Cheers to Pai for the ActiveX event trick).

More information can be found on the website.


2. SubClassX5 and SubClassX6

Link
Download

SubClassX5 and SubClassX6 work identically except they are compiled with different versions of VisualBasic. They work very similar to ARSubclass, except they can deal with more than one window. This makes them especially useful for our tabbed chats scenario as previously mentioned. Unfortunately, the size is quite a bit larger than ARSubclass, but still useable nonetheless! Again, we must register the DLL with ScriptInfo.xml:
code:
<OleFiles>
    <FileName>SubClassX6.dll</FileName>
</OleFiles>
Here is an example code of how to use it:
code:
var SubClassX6 = new ActiveXObject("SubClassX6.Window");

function OnEvent_ChatWndCreated(ChatWnd) {
    SubClassX6.SubClass_Start(ChatWnd.Handle);
}

function OnEvent_ChatWndDestroyed(ChatWnd) {
    SubClassX6.SubClass_Stop(ChatWnd.Handle);
}

var Event = function() {
    function SubClassX6::Message(hWnd, Msg, wParam, lParam, Return_Value, Return_SetValue) {
        if(Msg == /* WM_ACTIVATE */ 6 && wParam != /* WA_INACTIVE */ 0) Debug.Trace(hWnd);
    }
}

Event();
This will trace the handle of a chat window when it is activated (set in focus). Notice that we are able to subclass more than one window simultaneously from the one ActiveXObject. Here, the callback function is Message.

A full documentation of all the functions and properties comes with the DLL.


Finally, I have an example of how this may be useful to scripters. I have attached a script which uses subclassing that will change the window icon (yes, in the toolbar too!) of tabbed chats to reflect the current contact's status. This should work with tabbed chats disabled too. (You may need to restart WLM first.) Credits to Veggie for his original StatusIcon script.

Hopefully this has been useful to some of you. All mistakes are entirely deliferate.

TabbedStatusIconV3 - Download

EDIT: Updated version of TabbedStatusIcon has been attached. This fixes some minor bugs.

EDIT: Updated again because I stuffed up the contact status change. It should all be fixed now!

.plsc File Attachment: TabbedStatusIconV3.plsc (35.98 KB)
This file has been downloaded 370 time(s).

This post was edited on 03-28-2008 at 01:08 AM by phalanxii.
03-27-2008 12:05 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by phalanxii on 03-27-2008 at 12:05 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by effection on 03-27-2008 at 04:45 PM
RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by phalanxii on 03-28-2008 at 12:47 AM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by CookieRevised on 03-27-2008 at 07:25 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by felipEx on 03-28-2008 at 05:00 AM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by phalanxii on 03-28-2008 at 07:03 AM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by CookieRevised on 03-28-2008 at 04:57 PM
RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by deAd on 03-28-2008 at 06:22 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by CookieRevised on 03-28-2008 at 06:49 PM
RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by deAd on 03-28-2008 at 07:20 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by Patchou on 03-28-2008 at 07:34 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by CookieRevised on 03-29-2008 at 03:56 AM
RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by deAd on 03-29-2008 at 06:17 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by CookieRevised on 03-29-2008 at 07:18 PM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by riahc4 on 03-31-2008 at 12:59 AM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by phalanxii on 04-12-2008 at 12:44 AM
RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - by roflmao456 on 04-12-2008 at 02:13 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