[Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 - 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: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 (/showthread.php?tid=97202) [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 03:33 PM
Resolved! Thanks, matty! code: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? RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by matty on 03-24-2011 at 04:52 PM
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. RE: RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 05:02 PM
quote: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 RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by matty on 03-24-2011 at 05:06 PM
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? js code: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 RE: RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 07:28 PM
Oh, thanks! That looks rather awesome. quote: 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). RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by matty on 03-24-2011 at 08:33 PM
Check for the updated code in the post. My bad I was in a rush at work. So instead of passing Window.Handle try calling GetAncestor with either GA_PARENT or GA_ROOTOWNER RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 09:56 PM
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. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by matty on 03-24-2011 at 10:31 PM
quote:HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\PerPassportSettings\%Messenger.MyUserId%\DisableTabs 0: Enabled 1: Disabled RE: Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Matti on 03-24-2011 at 10:37 PM
The setting for tabbed chats in WLM 2011 is stored in the registry at quote: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. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 10:53 PM
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... RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by CookieRevised on 03-24-2011 at 10:56 PM
For stuff like checking what windows are created and which childs and parents there are, the well known developers tool Spy++ which comes with Visual Studio (or any other clone like Systree++) is essential. quote:You don't need to read it as a REG_BINARY if that binary string represents a DWORD (4 bytes). Just read it as a REG_DWORD in that case. As such, a full blown registry libary for just checking 1 value is also very much over the top. Reading that registry key can also be done using the build-in regkey functions. quote:Depends on what 'event' you mean. If it is just the OnEvent_ChatWndCreated function then there is nothing wrong with that. In fact, it would be essential to first check that registry key before you do anything else. Although it also highly depends if you can enable/disable tabbed chats in WLM 2011 on the fly though. If the user can only enable/disable it with a restart of WLM then doing the check in OnEvent_Initialize is sufficient, but if the user can change that setting whenever he wants you must always check the value before you do what you need to do (eg changing the icon of the chatwindow upon creation of that window). And as said above, you don't need any library to check just one registry value. Use the build in functions in JScript for that. quote:You wont find one because you should not be disabling scripts! You should use programming logic (IF THEN ELSE) to control what your script should do (or not do). RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Matti on 03-24-2011 at 11:08 PM
Disabling your script is not possible and is not such a great idea either. It's not up to the script to decide whether it should be enabled or not. Cookie's suggestion is much better. quote:I fully agree with you, but the RegRead function provided by WScript.Shell will return a VBArray of integers when reading from a REG_BINARY. It doesn't provide a way to override how the value is read, thus one will need to fall back on the Windows API functions to read as a different type. I don't know how a VBArray would look like in JScript though but it doesn't sound too great. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 11:10 PM
Ok, wow, thanks for all the info. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by matty on 03-24-2011 at 11:17 PM You need to check the registry value each time because Microsoft allows the user to, in real time, disable and enable tabbed chats. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by CookieRevised on 03-24-2011 at 11:26 PM
quote:Correct though (I forgot there was no second parameter to specify the type when you read a key). However, there is nothing difficult about a VBArray. In fact using toArray() is all it takes to convert it. js code:the join is just a trick to join all 'integers' elements together like a string to form one number (it doesn't matter what the joined value would be, since we're only interested in true or false, or "0000" or not "0000". Note that new Boolean(bTabsEnabled.toArray()[0]) could also be used, but then again, that wont work when the binary value would be something like '00 00 33 00'. RE: RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 11:27 PM
quote:Good point. I did just notice this myself while I was testing, and unfortunately no events get fired when the setting is changed. However, because of how I've structured my code, I can keep the registry check being done only when absolutely required. For instance, it would only ever need to be fired on a contact sign-in event, for example, if a conversation is open with that user. This should be fine! All I have to do now is figure out how I should be reading this value Fun! Edit: quote:Oh wow, ok, I guess you did it for me. Thanks! Lol! I had never expected this much help today. I really appreciate it, everyone RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by CookieRevised on 03-24-2011 at 11:33 PM
PS: note that I my example code I used RE: RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 11:38 PM
quote:Yep, thanks! I did notice, hehe. I was taking the code as advice rather than a complete copy-paste (I'm not actually as hopeless as I'm seeming in this thread, LOL! ) I think we also need to check ShowConvWndTabs anyway, right? RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by CookieRevised on 03-24-2011 at 11:41 PM
quote:in that case you must check the value in each and every event! Because between contact status changes for example, the user could have enabled/disabled tabbed chatting. In essence, you need to check the value each time your script manipulates (sets) the icon!! This said, depending on what your script _exactly_ does, and how WLM 2011 _exactly_ uses its container windows and what the function is of that other key (ShowConvWndTabs) - can't check, I don't run WLM 2011 atm- it may also be possible to simply forget about checking those registry keys, and simply check if the container window, for which you want to manipulate the icon, exists (which you should do anyways or your icon APIs might fail). It might be enough. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Domsy on 03-24-2011 at 11:46 PM
quote:Yep! Luckily, I did a main function that does this so I just need to modify that rather than each event Of course, you'd be expecting that of me anyway, hehe. I think there will be a slight issue if someone is to disable tabbed chats with conversations already open. No matter what, they'll all revert to the default icon and won't change until there's a relevant event update. I don't think I can avoid this, but it's no biggie... I don't expect tabbed chats to be enabled and disabled constantly all the time! It should be a one-time issue, and it's not disastrous anyway, hehe. This, luckily, doesn't apply to enabling tabbed chats as well, as the icon gets replaced with the default. Edit (crazy quote madness! lol): quote:Oh! Yes, I was wondering that myself... Ahhhhh! I'll investigate. I guess Spy++ should be handy (thanks for that! I have it with Visual Studio but have never used it). Edit 2: Looks like when you have tabbed chats disabled, every single conversation has it's own tab container (class: TabbedHostWndClass) whereas if tabbed chats is enabled, there's only one of them, which holds all the actual conversation windows (IMWindowClass). As far as I can tell, from that, it won't be of any help as you can't determine, this way, if tabbed chats is enabled or not unless you have more than one window, and it would be awkward to figure out anyway. I guess the registry option is the only way! (Unless I've missed something, which is probable, lol). Edit 3: All done! Works great so far! Thanks for all the help A little modification I had to make. It didn't seem to like the "new Boolean()" thing, and I had to typecast the join result as a Number. Ended up with: code:Without the typecasting, I think it was using a string literal of "0000". Thanks! Any of you willing to try it out before I make an attempt at releasing at some point? RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by matty on 03-25-2011 at 01:50 PM
Cookie couldn't you do something along these lines? js code: By the looks of things doing this will crash WLM as WaitForSingleObject is a synchronous call. You would have to externalize it. RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by CookieRevised on 03-25-2011 at 03:50 PM
As you found out, nope you can't because the scripting engine doesn't support such calls (same with subclassing). quote:... Yeah, my 'trick' always returned true, because apparently no matter what string you got, it always is converted to true as a boolean. I didn't tested it with a binary value of 0x0, sorry about that.... (seems strange that a string of "0" would result in true though - coming from VB point of view which does this automatic typecasting a lot better in this case ) So, all you indeed needed todo was to first convert that string into a number: bTabsEnabled = new Boolean((Number)(reg.toArray().join(''))); btw, this is the same (and shorter) and would work as expected too (as long as the binary value consists of 4 bytes): bTabsEnabled = reg.toArray().join('') != '0000' RE: [Resolved] Interop.Call SendMessageW not working since Plus 5/WLM 2011 by Matti on 03-25-2011 at 07:24 PM
Note that there actually is no such thing as type casting in JScript. It may look and work like type casting, but actually you're calling a function which happens to behave like a cast. js code:is identical to: js code:The Boolean() function acts like a cast, in the sense that it takes any variable and produces a boolean. When working with inheritance, the difference is much more clear. js code:When B inherits from A, one could try to cast an object b of class B to class A using something like (A)(b). However, this simply calls the function (constructor) A with the (unused) parameter b and thus this call returns void. Because JScript uses prototypical inheritance, such casting is simply not possible. Even with primitive types such as Number or Boolean, you'll always end up with a copy of the original. You probably won't even notice this since those primitive types don't compare by reference, but it happens. Another suggestion: don't use "new Boolean(o)" when converting to a boolean, either use "Boolean(o)" or "!!o". Here's why: js code:The explanation for this is that when using "new", you're always creating an object. The same happens with the "this" object, it's always an object - even when you're working on a primitive class! js code: So yes, either compare the string to '0000' or use a conversion such as: js code:or simply: js code:At least it'll have the proper type. |