[Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) - 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: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) (/showthread.php?tid=82705) [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by phalanxii on 03-27-2008 at 12:05 PM
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). 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:Here is an example code of how to use it: code: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:Here is an example code of how to use it: code: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! RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by effection on 03-27-2008 at 04:45 PM very very nice piece of work RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by CookieRevised on 03-27-2008 at 07:25 PM
quote:That's very possible iirc. quote:Also possible.... No need for an ActiveX for all of this. Just some API stuff... In fact, the ActiveXs do exactly what you already can do in Plus! by using the Windows API. Though using this ActiveX might be the easy solution for some. So, very good and nice find though ... But then again, some problems may arise when you use ActiveX (especially if more than one script is going to use the same one): quote:I actually do not recommend all of this (even including the use of <OleFiles>). (I think Patchou will shoot me now ) The reason is again that you will get into trouble when more than one script is going to use that DLL and you later install or remove even more scripts which use it. --------- As for the tabbed chat window example, I think that can be done much easier and with subclassing just 1 window. The hidden Plus! window which controls the tabs. RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by phalanxii on 03-28-2008 at 12:47 AM
quote:Thanks. quote:Would you be able to give an example of such a code (using only Plus! and the Windows API)? I'm quite interested in knowing how to do this. I didn't think it would be possible to have real-time events (when the windows messages are received), even with the new Interop.GetCallbackPtr() which only supports synchronous calls (I assume this means the calls are returned immediately). quote:I just experimented with this and noticed that it does cause a few problems. However, the ActiveX is not completely unregistered and the script's functionality returns to normal after restarting WLM. quote:Hmm... I tried subclassing just the hidden Plus! window, but I wasn't sure which message needed to be detected (WM_ACTIVATE doesn't work with it). The problem is that tabs can be changed with left mouse clicks as well as ctrl+tab on the keyboard. Also, subclassing each individual conversation window makes it easier to keep track of the current conversation handle. Suggestions? I've also updated the TabbedStatusIcon to fix a few bugs. RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by felipEx on 03-28-2008 at 05:00 AM
Hi :] code:* felipEx waits for Cookie's reply RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by phalanxii on 03-28-2008 at 07:03 AM
Thanks felipEx! It works fine over here too. I must say that it is also a lot more reliable than the ActiveX libraries and the script file size is obviously much smaller. quote:Would this be considered an asynchronous call? If this method is fine, I will release an updated TabbedStatusIcon (possibly in a separate thread). RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by CookieRevised on 03-28-2008 at 04:57 PM
quote:That's what I meant, yes. At phalanxii, hmmm, very good point. I guess this has something todo with the fact that scripts can be unloaded, removed, etc. But then again, as felipEx showed, you could handle that with Uninitialize() and ChatWndDestroyed() and stuff. Dunno really.... This is something for Patchou to answer I think: why it is that it isn't allowed, but still possible. Anyways, even if it wouldn't have been possible like that, you could also make a very small ActiveX dll which does the same as GetCallbackPtr(). I have used such an ActiveX a long time ago as kind of experiment, before GetCallbackPtr existed, and it worked nice. You call the ActiveX, the ActiveX returns a pointer you could use in a call to the SetWindowLongW API and you needed a var function (like the one used with Xniff and other ActiveX which call back to the script). And, but I never made this experiment yet, I think you could also device something with a Plus! Window of which you 'borrowed' the WinProc address to be used to overwrite the WinProc of another window. And with OnWindowidEvent_MessageNotification you can catch the window messages of that 'external' window. If this works, it also means you could subclass already long before GetCallbackPtr() existed. RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by deAd on 03-28-2008 at 06:22 PM
quote:I tried this once, but it doesn't work because you only have control over certain messages. You can't call the original window proc for messages you don't handle yourself because Plus! only tells you about the ones you ask for, and if you ask for everything you'll experience severe delays since JScript is so slow. RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by CookieRevised on 03-28-2008 at 06:49 PM Isn't the reason you want to subclass something because you need to catch just a certain message? I don't see why you would want to catch all possible messages there are, that would be useless (unless you make a Windows Message Spying program). RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by deAd on 03-28-2008 at 07:20 PM
quote:Yes, but you have to send the messages you don't want back to the original windowproc. You can't do this with a Plus! window because you only have control over the messages you ask for. RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by Patchou on 03-28-2008 at 07:34 PM
the only thing I'll say on this subject is: careful. Subclassing windows properly is something that takes time and anybody doing this kind of thing needs to make sure his code is tested extensively. RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by CookieRevised on 03-29-2008 at 03:56 AM
quote:But aren't all other messages already forwarded to the original WinProc by Plus!? Though I know this wouldn't work in all situations either though, and it is a bit of a dirty method. But I think this might be possible for specific things EDIT: Plus! doesn't know the original WinProc, that would of course be the reason, no? quote:I know this would be a lot to ask, but can you explain this in more detail and/or with an example, as I like to understand in much detail why it would cause a crash/unexpected results in some cases. EDIT: apparently not possible Just had a quick chat with Patchou. In short: quote:Now, he also gave a hint as in how it would be possible, but that involves asm (which _is_ possible in scripting, but extremely advanced). RE: RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by deAd on 03-29-2008 at 06:17 PM
quote:Yes, this is the reason. Plus! would call the default Windows message handler and the chat window's message handler would never see the messages. quote:It's very messy, but you can inject the ASM bytes of a new wndproc into memory and use a pointer to those. It's really better to just use a dll if you need to subclass. RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by CookieRevised on 03-29-2008 at 07:18 PM
quote:I know, hence why I said it is possible. I use ASM in one of my own private scripts... (which is not messy imo though, actually straightforward) RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by riahc4 on 03-31-2008 at 12:59 AM
quote:Thanks for the resource. Even though SOMEONE has to bitch about the hard work you went thru to make a scripter's life easier, I for one appreciate your time and work/effort. Also big thanks for "TabbedStatusIcon" but if its suppose to work like Veggie's Status Icon, it doesnt. At least not here: Vista Plus! 3.60 Messenger 9.0 RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by phalanxii on 04-12-2008 at 12:44 AM
Well, I certainly have no idea about ASM, but for those who are interested, deAd has explained how to do it in this separate thread. quote:I'm using XP at the moment with Plus! 3.60, but I have had confirmation that it works on Vista too. I don't know whether it works on Messenger 9.0 though, but I see no reason why it shouldn't. Perhaps you need to restart messenger? RE: [Resource] Subclassing ActiveXObjects (and [Release] TabbedStatusIcon too!) by roflmao456 on 04-12-2008 at 02:13 AM
quote:you can't use 3.60 with 9.0 what is the difference in this script and the Status Icon script? |