1

I'm trying to find a way to draw something on the screen that will show on top of anything else that is running (even full screen applications), but will not steal focus, or act like a normal application or window. It should be purely visual and not interfere in any other way.

Python is preferable.

What I'm aiming for is to be able to have my python script display a notification on the screen, possibly just some text (transparent background), and for it to show in front of whatever else you are doing at the time.

I've tried wxpython, but either the window steals focus, or I use the trick to not steal focus and it doesn't appear in front of my full screen applications. It feels like wxpython isn't really made for what I want to do, seeing as it's not supposed to be a GUI, it just supposed to be a notification that appears temporarily and takes no user input.

Acorn
  • 49,061
  • 27
  • 133
  • 172

2 Answers2

1

In general, you cannot write an application which guarantees to stay on top of other applications which want to stay on top of other applications.

Since a full-screen application is window which is topmost, there is no way for the OS to know that your topmost window needs to be topmoster than the other topmost window.

Ideally, you should find some way of cooperating with the other application.

However here are some tricks you can try, which may work for some situations:

  • You are probably going to have to use the Win32 API directly.
  • Don't activate your window using SetActive, just use SetWindowPos with SWP_NOACTIVATE and HWND_TOPMOST to move it to the front without activating.
  • Try setting your window to disabled, then it can't steal the focus, which is half the problem.
  • You may have to set SPI_SETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo to a small value.
  • You may have to try for foreground repeatedly until you get it.

Please note that these tricks will not help if the other window is doing the same thing.

Useful documentaion here:

Ben
  • 34,935
  • 6
  • 74
  • 113
0

If Qt is an option, you could try using the Qt::WA_ShowWithoutActivating attribute, as suggested in this question.

Community
  • 1
  • 1
steinar
  • 9,383
  • 1
  • 23
  • 37