6 ms·
How do I create a topmost window that is never covered by other topmost windows?
- maxklein 16y agoA solution would be to use DirectX and request exclusive access to the screen. It's rather unlikely any of the other apps are doing this. Using DirectShow it would not even be complex - could be done in just a few lines of code.
- shimonamit 16y agoUnfortunately that is not the case. Things like NetMeeting and other remote desktop control apps do the same.
- maxklein 16y agoThe FIRST app that gains control of the screen does not allow other apps do the same. Try it. Open Windows Media Player, play a video, then open VLC and play a video. You'll see that VLC output is pixelated - that's because it's rendering using RGB and not via hardware overlay.
- shimonamit 16y agoIn such a case an IT admin remote controlling a PC, or an employee goofing off with Windows Player will prevent my app from gaining exclusivity. That does not solve the problem. Also, exclusive access to the screen does not guarantee your program will go uninterrupted. Retaining exclusivity is impossible, because you just might get an ALT+TAB, CTRL+ALT+DEL or a WM_KILLFOCUS from who knows where. There are custom techniques for getting around each of those, but they're all along the lines of what's described in the article. Attaining and retaining exclusive access to the screen is next to impossible.
- maxklein 16y agoI'm not sure you get it. This is hardware overlay. It's not running in user-space, it's being moved from memory to graphic card directly. A DirectX drawn window is not affected by focus or anything else. You can stop it by killing the process. If someone came ahead of time to prevent it from ever gaining screen access, then that would be a problem, but since the order of app launches are known and can be controlled, it would still work.
- shimonamit 16y agoIn DirectX you will lose exclusive control of the screen and all rendering surfaces if your app loses focus. Retaining focus is not possible, unless by way of trickery. Game forums are riddled with developers trying to overcome this problem.
- maxklein 16y agoNot with DirectShow and the VMR filter.
- timrobinson 16y agoThis would beat the "enumerating all the windows in the system and calling ShowWindow(SW_HIDE)" program, but not: "setting their program as the screen saver, disabling the mouse and keyboard devices, and then invoking the screen saver on the secure desktop." or "enumerating all the processes on the system, attaching to each one with debug privilege, and suspending all the threads."
- maxklein 16y agoThe screensaver mode can be disabled. The enumerating thing will most likely lead apps to crash, so I am quite sure no other app is doing this, so it's safe to ignore.
- timrobinson 16y ago"The screensaver mode can be disabled" - the first app wants to enable the screen saver. The second app wants to disable it. What happens? "will most likely lead apps to crash" - you're a developer who's attempting to hack somebody else's app so that yours stays on top. This is a regular topic on Raymond Chen's blog - the kind of developer who does this isn't normally worried about a bit of crashing.
- sp332 16y agoI think disabling takes precedence over enabling. This is to prevent interruption of e.g. a movie the user is watching. I can't think of a use case where the user would want a program to start the screensaver even though another app has disabled it?
- maxklein 16y agoNo, look at the real life constraints of the problem. The screensaver can be prevented from starting by using SetThreadExecutionState or moving the mouse. Another app can't stop you from making the system unidle. And in the second part you're not paying attention to the constraints. If you want to simply kill all programs, that's easy in windows. The problem described above is to keep the system running, but become the topmost window. So a solution that causes crashes is not a solution. Crashing a windows program is trivially easy, and it would "solve" the problem, but that's not the right kind of solution.
- lukesandberg 16y agoYou are joking right? Because i could still just have my process kill your process and take over exclusive screen access... there's no winning this game.
- maxklein 16y agoRead the article - just ending processes is not allowed because those other processes need to continue to run. If you were allowed to end processes, then there would be no issue at all.
- lukesandberg 16y agoMaybe you should read the article; the point was that there's no way to win... so suggesting solutions is just as pointless as following the rules.
- jedsmith 16y agoYou remind me of that guy in the Farmer's Insurance commercial[1]. "You do realize that this is just an exercise, right?" [1]: http://www.youtube.com/watch?v=RNY98KN4p6c http://www.youtube.com/watch?v=RNY98KN4p6c
- kwantam 16y agoYou just... don't get it, do you Scott? (There is no way to win this game by giving the best solution to it. The better you get, the worse you get. In other words: the only way to win is not to play the game.)
- deleted 16y ago[deleted]
- Natsu 16y agoAlas, I still work with a program where someone had the bright idea to play tricks like this and, as a result, you can get error messages stuck completely behind an unmovable topmost window. Thankfully, there's one slightly obscure way to get Windows to move a window that's completely behind another window, but many people don't realize there's anything back there in the first place.
- daten 16y agoAnd what is that obscure method?
- Natsu 16y agoRight click it from the task tray and select move. Your mouse cursor will jump over to the top of the window (even if you can't see the window) and you will actually move the item you selected rather than the topmost window you appear to be clicking on. I called it "slightly obscure" because while the move option is perfectly normal, I had no idea that you could still select a window that was completely behind other windows. EDIT: And no, "close" wasn't among the options for that error.
- recoiledsnake 16y agoAlt + space then hit m, then use arrow keys. Try it now on a non maximized window.
- psykotic 16y agoOr you can select the window with alt-tab, press alt-space to open the window menu, press 'm' to select 'move' and then use the arrow keys. I use this all the time when windows go completely off screen and you can't grab them with the mouse. That can happen in all sorts of surprising ways.
- drv 16y agoAnd once you've moved it with an arrow key, you can then move it freely with the mouse until clicking.
- DanielBMarkham 16y agoI was going to chime in with my own ideas about solving this -- you can play this game all day long and I'm sure inciting that kind of discussion that was the intent of the author -- but this story about one particular request accidentally illuminates a key problem with Windows: too many developers and programs competing for one set of user eyeballs. You'd think that would be a good thing, but far from it. What happens is that every little developer writing any kind of tiny little app 1) wants money, and 2) wants to remind you how cool they and their app is by annoying you in various ways. Sadly, the annoying part is usually done without any unkind intent on the developer's part at all. I have no problem with the money thing, aside from it being annoying to pay for code that was just copied from MSDN and stuck in a wrapper, but the blinky-beepy-gotta-be-on-top thing is driving me nuts. The author uses an example of one guy who "knows" he wants the screen all the time, but the real underlying architectural problem is much more subtle (and worse) than that. Every program wants to tell the user something, maybe only once a month or so. That'd be fine, if there weren't dozens if not hundreds of programs running on the average setup. I've been using Ubnutu for the last couple months, mainly because Windows has become more like a video game, an XBox, than a serious operating system to me. When I started my windows O/S up the other day to do some multimedia chore after only two weeks without running it, every program I ran had updates and notices for me to attend to, including Windows itself. That made a 5 minute job take 2 hours, including the 15-minute boot time which was drug out because once I bought a Sprint modem, Sprint in its infinite wisdom wants to intercept and rework my network stack so they can "help me" use my computer better. This involves Sprint needing updates, resetting my wifi preferences every time it runs, forcing itself to run every time on boot, rewriting my access screens, and doing something with memory, thread, and priority allocation during boot that takes 5 minutes and can only be described from the user's standpoint as evil. And for all of my invective, I know they didn't mean it that way! As far as I know, they are honestly trying to provide assistance (assistance with lots of branding and subtle control over user behavior. Sigh) This is crazy. Windows has become like the web, only with one web page with everything you might ever want to do on it crammed in there and you can't navigate away. Somebody at Microsoft had better get on the ball and get rid of atomic updates, garbage collection, and vendor/programmer-induced interruptive bullshit. (Yes, there are ways to eliminate GC and the nightly install crapfest, but that's a longer story) If they don't, Google is going to eat their lunch. I'm afraid you can't have one O/S that is both extremely complex and consistent across millions of different use-cases. At least not structured like this.
- philthy 16y agoI believe XCode (I may be confusing the interface with RunRev Cards thing from a while ago though) has a simple check mark to make window a top most window on Mac. But I'm not sure if they can be scaled. Some of the Logic Pro and Final Cut tools function like this, where they are abovee everything.
- bajsejohannes 16y agoWhat if two applications has checked this box? That's the core of this article.
- praptak 16y agoYeah yeah, whatever. I don't want to hear about your problems. Having problems is a sign of incompetence. Just write me a program that always wins. While you're at it write me a program that always prints the biggest number. I expect both by tomorrow.
- CountSessine 16y agoDid I say tomorrow? Tomorrow's Saturday, isn't it? I meant Monday. You can do a bit of time this weekend, can't you?
- jerf 16y agoI can't help you with that first one, but perl -e 'while(1){print 9;}' A bit of a cheap shot as that is basically printing infinity without actually calling it infinity, but I'm going to float this by on a claim that your boss won't know the difference. "It's just not done yet, sir! Keep waiting. It's printing a really big number."
- deleted 16y ago[deleted]
- RyanMcGreal 16y agoThis is a classic arms race - an escalating conflict over a positional good that by definition can only be enjoyed by one entity at a time. Other positional goods include popularity in high school and military superiority (from which we get the term "arms race" to refer to the escalating efforts of multiple agents to achieve the good). Generally, the only effective way to address an arms race is regulation: an encorceable arms treaty, say, or a strict school uniform.
- adn37 16y agoCode injection (SetWindowsHookEx, WH_CBT) and API hooking allows to filter out other programs requesting topmost display. But this is intrusive. And it can be bypassed by other vendors, whether they workaround it by using other APIs/tricks or unhook their own process' APIs at runtime themselves. As said here in this thread, the only way to ensure full control is to patch the kernel (Window management related syscalls). And even there it's tricky to be exhaustive. VM is the safe way to go.
- _debug_ 16y agoI suppose it's issues like this that make tablet PC creators choose a single-tasking (or rather, single-app-controls-the-screen) model?
- WalterBright 16y agoPlease don't.
- jrockway 16y agoThe solution to this problem is to not let programs realize that there is a such thing as a window manager. "You have an x by y rectangle to draw in. There is no such thing as `other programs'. Enjoy." Then the end user can script these complex interactions in a way that pleases him. Composibility is better than following an arbitrary spec. UNIX gets this: I can program all my window interactions in Haskell. When mplayer wants to be fullscreen, it gets it. Everything else... nope, sorry. (Also, I have a solution! Run all the non-super-important programs in a VM. Then minimize the VM when your super-important program wants attention. This even composes properly when a more-super-important program comes along!)