简体   繁体   中英

Is there a way i can draw a transparent WPF application over the desktop at all times?

Is there a way to make an WPF application persist on top of the desktop when one uses the show desktop shortcut ( WINDOWS+D ) on windows?

I am trying to make an desktop overlay application with widgets. (Same concept as rainmeter) I currently am using functions in user32.dll to keep the window positioned on top of the desktop.

This works perfectly fine until i use WINDOWS+D

I've tried:

  • On the window Deactivated event, inserting the window's position above the Desktops position

  • Parenting the window to the desktop

Any suggestions would be greatly appreciated!

One (possibly dirty) way would be to register a hotkey to capture a WIN+D call as suggested in this answer: https://stackoverflow.com/a/824395/12167858

Once you have a way to capture the hotkey you can find out whether or not its trigger-event fires before or after the native WIN+D response (showing the desktop).

I did not test this myself just yet, however, if it does fire after the native response, you're good to go. Otherwise, if such a solution would be acceptable, you could use a Task.Delay() to wait for Windows to finish minimizing all visible windows.

/edit: I forgot the critical part: Once you have ensured that Windows is done doing its things, call the code below (as suggested here: https://stackoverflow.com/a/6837421/12167858 ) to get the window back to its original state:

if (myWindow.WindowState == WindowState.Minimized)
myWindow.WindowState = WindowState.Normal;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM