Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check whether or not open windows completely occlude the desktop?

Tags:

c#

.net

I'm writing a program in C# .net that changes the desktop background only when the desktop is not visible to the user, i.e. completely covered in some way by the currently open windows.

Ideally the solution would fire an event whenever it detected a change in the desktop's visibility, but right now T'm not even sure how to check visibility in the first place, other than scanning every pixel (incredibly inefficient) or periodically looping through all open windows and checking their dimensions (still inefficient and I've no idea how to implement.)

I've been fooling around with Windows.Forms.Screen and the user32.dll methods listed here, but haven't managed to figure out anything effective.

Many thanks to anyone kind enough to help!

like image 439
PieFlinger Avatar asked Aug 22 '11 23:08

PieFlinger


1 Answers

You could just detect when another Windows application is running in full screen mode, which is simplier to detect and more likely than the desktop being covered up by a patchwork of windows.

Example code here: http://www.richard-banks.org/2007/09/how-to-detect-if-another-application-is.html

like image 179
Peter Bridger Avatar answered Oct 20 '22 15:10

Peter Bridger