Shoutbox

Finding a window and stopping it from displaying - 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: Finding a window and stopping it from displaying (/showthread.php?tid=91044)

Finding a window and stopping it from displaying by ryxdp on 06-13-2009 at 07:39 AM

How would I go about regularly checking whether this window exists:

WMP9MediaBarFlyout1342137C

and then stop it from becoming visible using some means (I guess DestroyWindow would be sufficient here)? I'd imagine FindWindowEx would be needed, but I don't know where to start; I need to find a practical way of regularly checking on the window, as in, when it happens, not every five seconds or so.

Thanks in advance :P


RE: Finding a window and stopping it from displaying by SmokingCookie on 06-13-2009 at 02:31 PM

Dunno if one can actually "block" windows, but you can indeed find it and close it:

JScript code:
function FindWindow(hWndParent,lpszClass,lpszWindow) {
    if(typeof hWndParent !== "number") hWndParent = 0;
    if(typeof lpszClass !== "string") lpszClass = 0; // NULL
    if(typeof lpszWindow !== "string") lpszWindow = 0; // NULL
    var hWndReturn = 0;
    do {
        hWndReturn = Interop.Call("User32.dll","FindWindowExW",hWndParent,hWndReturn,lpszClass,lpszWindpw);
    } while(hWndReturn !== 0)
    return hWndReturn;
}

function CloseWindow() {
    Interop.Call("User32.dll",
    "DestroyWindow",
    FindWindow(0 /* do you have a parent window? */,
        "WMP9MediaBarFlyout1342137C" /* I think it's the class name you're talking about? */));
}

Should work this way. Note that if "WMP9MediaBarFlyout1342137C" the window title (and not the class name), you need to send 0, 0 and WMP9MediaBarFlyout1342137C respectively.
RE: Finding a window and stopping it from displaying by TheSteve on 06-15-2009 at 05:02 AM

If you write a DLL (then load it from plus), you can use it to install a CBT hook which will allow you to filter windows as they are created.

See SetWindowsHookEx and HCBT_CREATEWND in CBTProc


RE: Finding a window and stopping it from displaying by SmokingCookie on 06-15-2009 at 06:23 AM

Is that actually possible? Cuz I think the pointer to CBTProc is asynchronous.


RE: Finding a window and stopping it from displaying by ryxdp on 06-15-2009 at 07:15 AM

I guess I should explain a bit more. All I want is a simple way to check whether this popup window exists:

[Image: attachment.php?pid=965655]

and get rid of it by some means, most likely DestroyWindow. It looks like the parent window is indeed the desktop, and it is the class name, so the script should work, but it doesn't seem to be able to find the window, just keeps giving me 0.

The reason why I want to get rid of it is because when I change tracks in WMP, it pops up.

I hope they get rid of that in WMP11


RE: RE: Finding a window and stopping it from displaying by TheSteve on 06-15-2009 at 01:37 PM

quote:
Originally posted by SmokingCookie
Is that actually possible? Cuz I think the pointer to CBTProc is asynchronous.
As long as the DLL stays loaded, it shouldn't be a problem.  (the CBTProc would need to be in the DLL, and you may as well install the hook from inside the DLL as well.)

quote:
Originally posted by ryxdp
but it doesn't seem to be able to find the window, just keeps giving me 0.
Are you sure the class name is "WMP9MediaBarFlyout1342137C" and not just "WMP9MediaBarFlyout"?  If the window exists and you've got the class name correct, it *should* be found.  How are you determining the class name?  Spy++?
RE: RE: RE: Finding a window and stopping it from displaying by ryxdp on 06-16-2009 at 07:41 AM

quote:
Originally posted by TheSteve
Are you sure the class name is "WMP9MediaBarFlyout1342137C" and not just "WMP9MediaBarFlyout"?  If the window exists and you've got the class name correct, it *should* be found.  How are you determining the class name?  Spy++?

I'm using Winspector:

[Image: attachment.php?pid=965779]
RE: Finding a window and stopping it from displaying by TheSteve on 06-17-2009 at 03:00 PM

Try tracing out the parameters right before the call to FindWindowExW.  Make sure that they are being passed correctly. (not getting messed up by the "typeof var")


RE: Finding a window and stopping it from displaying by ryxdp on 06-18-2009 at 10:17 AM

Well, it looks like the DestroyWindow function is failing, which suggests (to me) that WMP is somehow preventing it from being destroyed...


RE: Finding a window and stopping it from displaying by Mnjul on 06-18-2009 at 06:33 PM

You can't DestroyWindow() another program's window:

quote:
MSDN - DestroyWindow() Function
A thread cannot use DestroyWindow to destroy a window created by a different thread.


Please nicely send WM_CLOSE message to that window and let it decide whether to close or not :p
RE: RE: Finding a window and stopping it from displaying by ryxdp on 06-19-2009 at 07:33 AM

quote:
Originally posted by Mnjul
You can't DestroyWindow() another program's window:

quote:
MSDN - DestroyWindow() Function
A thread cannot use DestroyWindow to destroy a window created by a different thread.


Please nicely send WM_CLOSE message to that window and let it decide whether to close or not :p

Yeah, I saw that when I was looking at the function, but I didn't really think about it :(

Anyway, it now closes properly. Thanks for your help :)
RE: Finding a window and stopping it from displaying by CookieRevised on 06-19-2009 at 09:41 AM

erm... isn't there an option to not show that small popup window to begin with?
Or at least an option that it closes automatically once it popped up.

I don't have the time atm to find out, but from what I remember from using the small WMP toolbar it simply popped up that small window when you start to play something and closes again a few seconds. And you could also set it to permanently show that small windows, so.....

but I might remember incorrectly though...

EDIT:

quote:
Originally posted by ryxdp
The reason why I want to get rid of it is because when I change tracks in WMP, it pops up.

I need to read better... :$

anyways, it only pops up for 2 seconds so I don't see the real problem, but meh...
RE: RE: Finding a window and stopping it from displaying by ryxdp on 06-19-2009 at 10:00 AM

quote:
Originally posted by CookieRevised
anyways, it only pops up for 2 seconds so I don't see the real problem, but meh...

Well, when I'm using a full-screen CD Art Display skin, it's very annoying when a tiny little window pops up with the same information that's being displayed over the whole screen anyway. I really hope WMP11 gives us more control over this toolbar...
RE: Finding a window and stopping it from displaying by CookieRevised on 06-19-2009 at 10:08 AM

The toolbar should only show up when WMP is minimized.

Or maybe don't use the small wmp toolbar? dunno...
(You can disable it by right clicking on the Windows toolbar and unticking Windows Media Player in the Toolbars submenu)

Or skin the wmp toolbar too (so it doesn't/can't show the small pop up)...

blah, probably stuff you already know though :p


RE: Finding a window and stopping it from displaying by Matti on 06-19-2009 at 01:22 PM

Yeah, well the WMP toolbar has the annoying habit to immediately pop up that fly-out whenever you move your mouse over it, and then there is no way to quickly close it again, you simply have to wait those 2 to 3 seconds. Very annoying when you're running Firefox maximized and want to click an icon of an addon in the browser's statusbar when suddenly... WMP! :P


RE: Finding a window and stopping it from displaying by CookieRevised on 06-19-2009 at 10:41 PM

quote:
Originally posted by Matti
Yeah, well the WMP toolbar has the annoying habit to immediately pop up that fly-out whenever you move your mouse over it, and then there is no way to quickly close it again, you simply have to wait those 2 to 3 seconds. Very annoying when you're running Firefox maximized and want to click an icon of an addon in the browser's statusbar when suddenly... WMP! :P
lol, I have that with Messenger toasts ALL the time, hehehe.... At the most inconvenient moment somebody always thinks it is fun the sign in, sign out, sign in, sign out... or to start zapping thru their playlist (I realy need to disable the notification for media updates from certain people :p)....

Anyways, I'm not into skinning, but you can make your own WMP skins, no? If that is the case, can't you make a skin where the fly-out is disabled or something (or is only 1px big or whatever)?

Thinking of it... You ask for a API to use in a Plus! script to hook that window so you can close that window. But what about creating your own (very little) addon for WMP which simply does the same thing? In that way, you don't need Plus! to do the job, and you will always be certain that the hook is loaded when you run WMP, even if you don't run Messenger, etc...
RE: RE: Finding a window and stopping it from displaying by ryxdp on 06-19-2009 at 11:06 PM

quote:
Originally posted by CookieRevised
Anyways, I'm not into skinning, but you can make your own WMP skins, no? If that is the case, can't you make a skin where the fly-out is disabled or something (or is only 1px big or whatever)?

I replaced the image with an empty file, here's the results:

[Image: attachment.php?pid=966245]

I thought something like this would happen :P

quote:
Thinking of it... You ask for a API to use in a Plus! script to hook that window so you can close that window. But what about creating your own (very little) addon for WMP which simply does the same thing? In that way, you don't need Plus! to do the job, and you will always be certain that the hook is loaded when you run WMP, even if you don't run Messenger, etc...

I do like this idea, but how would I do that? Do I need to build my own DLL? What language does it use?
RE: Finding a window and stopping it from displaying by foaly on 06-20-2009 at 10:43 PM

normally this is really easy to do with autohotkey,
but from what I tried it doesn't seem to find the window...
see for example this forum post on how to prevent a window from opening:
http://www.autohotkey.com/forum/topic13330.html&h...ght=window+blocker


RE: Finding a window and stopping it from displaying by CookieRevised on 06-22-2009 at 06:22 PM

I guess simply removing the background image isn't enough because the window is still created and all. This is much like Plus!-skinning or any other skinning. You probably need to remove (or hide) other elements as well.

Everything about WMP plugins, including examples how to create them, Visual Studio Plugin Wizard explanation, etc, can be found on MSDN: http://msdn.microsoft.com/en-us/library/aa393415.aspx
There are several types of plugins you can create.

Thousands of plugins (maybe already something which you can use, or look in to as an example) can be found on http://www.wmplugins.com/.