QtCore.Qt.WindowStaysOnTopHint not staying on top of DirectX windows

Alberto Paris albertoparis1 at outlook.com
Fri Jul 10 17:01:58 BST 2020


Good morning,


I am trying to make a PyQt5 window (OS=MS Windows 10) that will stay on top of absolutely everything on my screen (like an overlay). For this, I am using:

    self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.WindowTransparentForInput)

So far it works perfectly with any regular window (Word, Excel, browsers, etc.). However, the behavior changes when the app I am trying to be on top of is a DirectX game.

  *   If I run the Python script before the game, it will show on top of it, and work fine. However, if I Alt-Tab out of the game and come back to it, the overlay will not show anymore on top the game (It will still show on top of all other windows, just not on top of the game).
  *   If I start the game before the Python script, same thing: It will show on top of everything, but not on top of the DirectX game.
  *   When I run the Python script, then the game, then Alt-Tab out of the game and Alt-Tab in, so it stops showing in-game, I can make it reappear if I exit and re-run the game from scratch (without stopping the Python script).

A good example of an script where this behavior can be seen is: https://github.com/georgegach/crosshair/blob/master/cross.py

Is there any option to make this PyQt5 window stay on top of absolutely everything, until stopped?


Thank you,


Alberto Paris



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200710/fd8985c3/attachment.htm>


More information about the PyQt mailing list