1

I'm working on an app that creates a desktop wallpaper diashow (for multi-monitor-setups). I want to skip displays which are not visible, when some other app runs in fullscreen for example.

EDIT

I set wallpapers using the IDesktopWallpaper interface, which needs a DeviceId.
I managed to get the DeviceNames (like \.\DISPLAY1) and the DeviceIds (like \?\DISPLAY#GSM76FE#5&3b13964d&0&UID4354#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}) using EnumDisplayDevices.

Now I'm trying to get their corresponding desktops, to get all windows on that desktop, to check if they cover that desktop.

I tried EnumDesktops, like stated here, but it only returns the names "s" and "D" for me, and I can't OpenDesktop them (it returns a null handle, GetLastError returns 2).

Fox
  • 566
  • 4
  • 14
  • Does this answer your question? [Is there a way to check to see if another program is running full screen](https://stackoverflow.com/questions/3743956/is-there-a-way-to-check-to-see-if-another-program-is-running-full-screen) – avocadoLambda Jun 20 '20 at 20:36
  • 1
    @Peter Interesting, but no. For example, if the user plays a game on the main monitor in fullscreen, that game will be the window returned by GetForegroundWindow(), but I still need to know if something on the second monitor is in fullscreen. – Fox Jun 20 '20 at 21:02
  • 5
    There is no way to check for this, unless you are willing to go to length and evaluate any possible combination of windows that will result in a fully obscured desktop. That may sound trivial, just taking the window rectangles and adding them up. But then there are layered windows, either with key color or alpha transparency. And since WinUI seems to love the acrylic brush so much, you'll have to consider another (blurred) transparency mode. – IInspectable Jun 20 '20 at 21:07
  • @IInspectable You're right. Actually, maybe I want to do that. At first I thought about only checking if any window runs in fullscreen, but when I'm checking every window anyways I can also sum their rectangles. I'm not that worried about blurry or glass-style windows, as even then the background may not be that important. I'll have to look into completly transparent windows though. Thank you. – Fox Jun 21 '20 at 07:44
  • You can use [`WindowFromPoint`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-windowfrompoint?redirectedfrom=MSDN) to check if the left-top and right-bottom points belong to a same application. If it is true, the application is in fullscreen mode. – Rita Han Jun 22 '20 at 05:46
  • @RitaHan-MSFT Atm I struggle with getting the desktop of a specific monitor. How does the desktop even work in a multi-monitor setup? – Fox Jun 22 '20 at 08:25
  • What's kind of multi-monitor setup? Do you want to detect an application in fullscreen on a single monitor or across multiple monitors? – Rita Han Jun 22 '20 at 08:48
  • @RitaHan-MSFT On a single monitor. I want to know which monitors are occupied, and which not. – Fox Jun 22 '20 at 08:52
  • Same method on per monitor. Get every monitor left-top and right-bottom point and compare the two points to see if they belong to a same application window. – Rita Han Jun 22 '20 at 09:24
  • @RitaHan-MSFT Okay, but I struggle to get the desktop windows, because I can't get a desktopHandle. I do it like [here](https://stackoverflow.com/questions/13323174/all-desktops-named-by-enumdesktops-fail-to-opendesktop-with-error-2-file-not-fo), but OpenDesktop always returns a null handle :/ – Fox Jun 22 '20 at 10:01
  • @rit This is an over-simplification, that ignores windows that have called [SetWindowRgn](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowrgn), for example. – IInspectable Jun 22 '20 at 12:17
  • @Fox It seems you have multiple desktops associate different monitors. Do you use multiple monitors as independent displays and every independent display has its own desktop? – Rita Han Jun 23 '20 at 08:22

0 Answers0