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

Pages: (3): « First [ 1 ] 2 3 » Last »
[Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011
Author: Message:
Domsy
Junior Member
**

Avatar

Posts: 31
35 / Male / Flag
Joined: Jun 2006
O.P. [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011
Resolved! Thanks, matty!

Hi everyone,

I've been avoiding updating to WLM 2011 and Plus 5 on my main machine for a while now because of a huge issue with one of the scripts I've developed. Basically, it adjusts the taskbar icon for the chat conversation depending upon the contact's current status. It works perfectly on Plus 4.9 with WLM 2009, but when using the exact same script with Plus 5 and WLM 2011 on another machine, it just doesn't. This feature has become essential for me and I just cannot update without it.

My issue is this function I wrote doesn't seem to work anymore:
code:
function ChangeIcon(Window, Icon)
{
    var icon = Interop.Call("user32.dll", "LoadImageW", null, Icon, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
    Interop.Call("user32.dll", "SendMessageW", Window.Handle, WM_SETICON, ICON_SMALL, icon);
    Interop.Call("user32.dll", "SendMessageW", Window.Handle, WM_SETICON, ICON_BIG, icon); // Required for bigger icon for Windows 7
}
Can anyone please give me some advice on why this is? I cannot explain it. What would be stopping this from suddenly working? It works perfectly before :(

Without this working, I also cannot hope to release the script on the site for others to use.

Thank you very much!

Also, just as a notice, tabbed chats has to obviously be disabled for this to be of any benefit.

Edit: I just did a test to determine if Plus 5 or WLM 2011 is at fault, and it seems it's WLM 2011. I installed WLM 2009 with Plus 5 on my other machine and the script still works fine, so it's a change made with WLM 2011 that's causing the problem. Anyone know what is causing this?

This post was edited on 03-24-2011 at 10:11 PM by Domsy.
03-24-2011 03:33 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
Last time I looked (investigated) it was something to do with tabbed chats and their container they were placed in. Now since you have disabled tabbed chats it should work.

I just bought a netbook as my main laptop died and obviously programming on a 10 inch screen is next to impossible. Therefore unfortunately I cannot help you any further than this at the moment (plus I am at work).

This post was edited on 03-24-2011 at 04:54 PM by matty.
03-24-2011 04:52 PM
Profile E-Mail PM Find Quote Report
Domsy
Junior Member
**

Avatar

Posts: 31
35 / Male / Flag
Joined: Jun 2006
O.P. RE: RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
quote:
Originally posted by matty
Last time I looked (investigated) it was something to do with tabbed chats and their container they were placed in. Now since you have disabled tabbed chats it should work.

I just bought a netbook as my main laptop died and obviously programming on a 10 inch screen is next to impossible. Therefore unfortunately I cannot help you any further than this at the moment (plus I am at work).
Thanks for taking an interest!

Yeah, I was wondering if it was anything to do with the tabbed chats that WLM themselves introduced, but as you said, I've disabled them and it still doesn't work. Still, I'm not sure why the interop call should fail, regardless.

If it would help, I could send you the whole script later when you are available? Although the only part that actually seems to be affected is the function I posted.

Perhaps if nothing else can be figured out, would there be an alternative, perhaps more aggressive, way to change the icon? I'm wondering if it could be done via a custom DLL (maybe C# or something, if C# is capable of doing that without further DLLs, lol). I have no experience with Plus scripts interacting with C# DLLs though, so I'd be at a loss.

Thanks :)

This post was edited on 03-24-2011 at 05:03 PM by Domsy.
03-24-2011 05:02 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
When you say SendMessageW is failing do you mean the icon just isn't being applied (which is what I assume). What is the return value of the function call?

What I would like you to try is this:

Javascript code:
function OnEvent_ChatWndCreated(pChatWnd) {
    /*
   
        Value           Meaning
        GA_PARENT(1)    Retrieves the parent window. This does not include the owner, as it does with the GetParent function.
        GA_ROOT(2)      Retrieves the root window by walking the chain of parent windows.
        GA_ROOTOWNER(3) Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent.
       
    */

   
    var hWnd;
    var MAX = 255;
    for (var i=1;i<4;i++) {
        hWnd = Interop.Call('user32', 'GetAncestor', pChatWnd.Handle, i);
        var lpszClassName = Interop.Allocate(2*MAX+2);
        Interop.Call('user32', 'GetClassNameW', hWnd, lpszClassName, lpszClassName.Size);
        Debug.Trace('i :: '+i);
        Debug.Trace('   pPlusWnd.Handle :: '+pChatWnd.Handle);
        Debug.Trace('   hWnd :: '+hWnd);
        Debug.Trace('   lpszClassName :: '+lpszClassName.ReadString(0));
        lpszClassName.Size = 0;
    }
}

Wondering if the Chat Window is still in a container. Running the code will tell us who the parent (if any) is.

Codes ugly I know :P

This post was edited on 03-24-2011 at 08:34 PM by matty.
03-24-2011 05:06 PM
Profile E-Mail PM Find Quote Report
Domsy
Junior Member
**

Avatar

Posts: 31
35 / Male / Flag
Joined: Jun 2006
O.P. RE: RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
Oh, thanks! That looks rather awesome.

Unfortunately, it seems it can't locate GetClassName in user32 :| That's weird...
quote:
Interop.Call failed to locate function "GetClassName"

Also, I don't see a definition for pPlusWnd. Is that meant to be pChatWnd?

Edit: Oh and is that a semicolon missing on the hWnd assignment line? Weird how that didn't produce an error.

Edit2: Oh, and yes, sorry... By failing, I meant it just wouldn't assign the icon. The function call seemed fine (can't confirm this very second as I'm waiting for Live Essentials to reinstall after I tested out 2009).

This post was edited on 03-24-2011 at 07:46 PM by Domsy.
03-24-2011 07:28 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
Check for the updated code in the post. My bad I was in a rush at work.

And just as I suspected. There is still a container around the chat windows:

With tabbed chats enabled (opened 2 chats)
Function called: OnEvent_ChatWndCreated
i :: 1
   pPlusWnd.Handle :: 722674
   hWnd :: 722626
   lpszClassName :: MsgrViewHost View Host
i :: 2
   pPlusWnd.Handle :: 722674
   hWnd :: 722620
   lpszClassName :: TabbedHostWndClass
i :: 3
   pPlusWnd.Handle :: 722674
   hWnd :: 722620
   lpszClassName :: TabbedHostWndClass
Function called: OnEvent_ChatWndCreated
i :: 1
   pPlusWnd.Handle :: 788166
   hWnd :: 722626
   lpszClassName :: MsgrViewHost View Host
i :: 2
   pPlusWnd.Handle :: 788166
   hWnd :: 722620
   lpszClassName :: TabbedHostWndClass
i :: 3
   pPlusWnd.Handle :: 788166
   hWnd :: 722620
   lpszClassName :: TabbedHostWndClass

Tabbed chats disabled (opened 2):
Function called: OnEvent_ChatWndCreated
i :: 1
   pPlusWnd.Handle :: 591454
   hWnd :: 787436
   lpszClassName :: MsgrViewHost View Host
i :: 2
   pPlusWnd.Handle :: 591454
   hWnd :: 722550
   lpszClassName :: TabbedHostWndClass
i :: 3
   pPlusWnd.Handle :: 591454
   hWnd :: 722550
   lpszClassName :: TabbedHostWndClass
Function called: OnEvent_ChatWndCreated
i :: 1
   pPlusWnd.Handle :: 1049672
   hWnd :: 853746
   lpszClassName :: MsgrViewHost View Host
i :: 2
   pPlusWnd.Handle :: 1049672
   hWnd :: 721894
   lpszClassName :: TabbedHostWndClass
i :: 3
   pPlusWnd.Handle :: 1049672
   hWnd :: 721894
   lpszClassName :: TabbedHostWndClass



So instead of passing Window.Handle try calling GetAncestor with either GA_PARENT or GA_ROOTOWNER

This post was edited on 03-24-2011 at 08:45 PM by matty.
03-24-2011 08:33 PM
Profile E-Mail PM Find Quote Report
Domsy
Junior Member
**

Avatar

Posts: 31
35 / Male / Flag
Joined: Jun 2006
O.P. RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
OMG! Thank you so much! You are awesome! I had thought it was something to do with tabbed chats, but I didn't know why, and why it would still be an issue even with them disabled.

I've managed it with GA_ROOTOWNER and it works again! YAY!

Thank you! All I need to figure out now, if it's possible, is to detect if tabbed chats are enabled or not, and not to update the icon if not, but it's not that crucial as anyone who would use this when I release it would have them disabled anyway. Still, it would be nice to just avoid it doing it.

Thank you again! I'll consider releasing it at some point soon as others should hopefully benefit from this as well :)
03-24-2011 09:56 PM
Profile PM Find Quote Report
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
quote:
Originally posted by Domsy
All I need to figure out now, if it's possible, is to detect if tabbed chats are enabled or not, and not to update the icon if not, but it's not that crucial as anyone who would use this when I release it would have them disabled anyway. Still, it would be nice to just avoid it doing it.
HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\PerPassportSettings\%Messenger.MyUserId%\DisableTabs
0: Enabled
1: Disabled

This post was edited on 03-24-2011 at 10:32 PM by matty.
03-24-2011 10:31 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011
The setting for tabbed chats in WLM 2011 is stored in the registry at
HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\PerPassportSettings\USERID
under the binary registry value ShowConvWndTabs. This REG_BINARY value consists of 4 bytes representing a little-endian 32-bit integer which equals 1 (01 00 00 00) when tabbed chats are enabled or 0 (00 00 00 00) when they are disabled. Actually, this format is identical to REG_DWORD which defaults to little-endian.

Normally, you should only have to read the value and check whether it's non-zero to determine the state. :)

As for reading a REG_BINARY from the registry, you'll probably want to use some registry functions for that. Screenshot Sender 5 comes with a nifty set of registry functionalities which support REG_BINARY. Feel free to use that script file but please credit the original authors in a comment block at the top of the file.

However, the Screenshot Sender implementation reads binary values as strings where each two bytes represents a Unicode character (as it's mainly used for string data in the script). If you're planning to use this, you'll either need to modify Registry_GetKeyValue to read the value as a number or convert the string data to a number first after calling Registry_GetKeyValue. That's up to you. ;)


quote:
Originally posted by matty
HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\PerPassportSettings\%Messenger.MyUserId%\DisableTabs
0: Enabled
1: Disabled
That registry value doesn't seem to reflect the tabbed chats setting... I think it's some kind of leftover from previous versions for the tabs in the contact list. ShowConvWndTabs does reflect the correct setting though.

This post was edited on 03-24-2011 at 10:39 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
03-24-2011 10:37 PM
Profile E-Mail PM Web Find Quote Report
Domsy
Junior Member
**

Avatar

Posts: 31
35 / Male / Flag
Joined: Jun 2006
O.P. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011
Oh, wow, thanks! That's quite involved just to check for something that's not too crucial in my case, particularly if I'm going to be doing that every single event (not sure how heavy registry checks are)... May not be worth it...

Might be best to check this value once on OnEvent_Intialize and if it's enabled, notify the user and disable the script.

... except I can't seem to find a disable script command. Doh... Is there one? Lol. Maybe an 'artificial disable' would be needed instead, but that's extra script that's probably not worthwhile.
03-24-2011 10:53 PM
Profile PM Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« Next Oldest Return to Top Next Newest »


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