Detecting Gadget visibility / screen saver & power saving state
Is there anyway to detect if a gadget is visible or covered by other applications or if the screen saver / display power saver is on?
I'm creating kind of a slide show gadget which will download images from an external server and it's wasting of server bandwidth to keep downloading the images when the gadget isn't shown so I need some ways to detect when the gadget should be suspended.
You can detect if it's visible on the Sidebar, see my comments in
this thread. You can't however tell if another application is covering it, the screen saver is on, or the display is in power save.
This could however be done with an ActiveX COM. For the window overlap, you'd have to step through all the active window handles and then check their screen position against yours.
FYI: Gadgets have a class is "BasicWindow" and the caption will be the Gadget title.
Hmm, seems that the visibilityChanged-event is launched either with the screen saver or the power save at least every now and then, not always though. Need to explore it a little further, but thanks for the info. =)
The visibilityChanged event will fire in response to OS changes of a broad sort, plus the really obvious case of the gadget being pushed onto a second page of the Sidebar. I'd recommend listening for the event and then checking the state, and not assuming that the state toggles. We don't have a definitive list of things that cause the event to fire - but it's things like the user locking the workstation, screensavers, and so forth.
Brian