[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    QtCore.Qt.WindowStaysOnTopHint not staying on top of DirectX windows
From:       Alberto Paris <albertoparis1 () outlook ! com>
Date:       2020-07-10 16:01:58
Message-ID: BN7PR08MB475354517FA7339D65C7B136F7650 () BN7PR08MB4753 ! namprd08 ! prod ! outlook ! com
[Download RAW message or body]

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


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; \
font-size: 12pt;"> <span><br>
</span></div>
<div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; \
font-size: 12pt;"> Good morning,</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; \
font-size: 12pt;"> <br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; \
font-size: 12pt;"> <p style="border-bottom-color: currentColor; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
clear: both; color: rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; \
margin-bottom: 1em; margin-top: 0px"> 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:</p> <span style="display: inline !important; \
background-color: rgb(255, 255, 255); color: rgb(36, 39, 41); font-family: \
Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif; font-size: 15px; \
font-size-adjust: none; line-height: 1.3; overflow-wrap: break-word"></span> <pre \
style="background-color: var(--black-050); border-bottom-color: currentColor; \
border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
border-top-left-radius: 3px; border-top-right-radius: 3px; color: var(--black-800); \
display: block; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation \
Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif; \
font-size: 13px; font-size-adjust: none; margin-bottom: 1em; margin-top: 0px; \
max-height: 600px; overflow: auto; padding-bottom: 12px; padding-left: 8px; \
padding-right: 8px; padding-top: 12px; width: auto"><code style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px"><span style="border-bottom-color: currentColor; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
color: var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">&nbsp; &nbsp; self</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: var(--black-750); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">.</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: \
var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">setWindowFlags</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: var(--black-750); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">(</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: rgb(43, 145, 175); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">QtCore</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: \
var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">.</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: rgb(43, 145, 175); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">Qt</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: var(--black-750); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">.</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: rgb(43, 145, \
175); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; margin-top: \
0px">FramelessWindowHint</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: var(--black-750); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">&nbsp;</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: var(--black-750); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">|</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: \
var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">&nbsp;</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: rgb(43, 145, 175); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">QtCore</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: var(--black-750); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">.</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: rgb(43, 145, \
175); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; margin-top: \
0px">Qt</span><span style="border-bottom-color: currentColor; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
color: var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">.</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: rgb(43, 145, 175); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">WindowStaysOnTopHint</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: \
var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">&nbsp;</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: var(--black-750); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">|</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: var(--black-750); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">&nbsp;</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: rgb(43, 145, \
175); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; margin-top: \
0px">QtCore</span><span style="border-bottom-color: currentColor; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
color: var(--black-750); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px">.</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: rgb(43, 145, 175); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">Qt</span><span style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: var(--black-750); font-size: 100%; \
font-size-adjust: none; margin-bottom: 0px; margin-top: 0px">.</span><span \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: rgb(43, 145, \
175); font-size: 100%; font-size-adjust: none; margin-bottom: 0px; margin-top: \
0px">WindowTransparentForInput</span><span style="border-bottom-color: currentColor; \
border-left-color: currentColor; border-right-color: currentColor; border-top-color: \
currentColor; color: var(--black-750); font-size: 100%; font-size-adjust: none; \
margin-bottom: 0px; margin-top: 0px">)</span></code></pre> <span style="display: \
inline !important; background-color: rgb(255, 255, 255); color: rgb(36, 39, 41); \
font-family: Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif; font-size: 15px; \
font-size-adjust: none; line-height: 1.3; overflow-wrap: break-word"></span> <p \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; clear: both; color: \
rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; margin-bottom: 1em; \
margin-top: 0px"> 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.</p> <span style="display: inline !important; background-color: \
rgb(255, 255, 255); color: rgb(36, 39, 41); font-family: Arial,&quot;Helvetica \
Neue&quot;,Helvetica,sans-serif; font-size: 15px; font-size-adjust: none; \
line-height: 1.3; overflow-wrap: break-word"></span> <ul style="border-bottom-color: \
currentColor; border-left-color: currentColor; border-right-color: currentColor; \
border-top-color: currentColor; color: rgb(36, 39, 41); font-size: 100%; \
font-size-adjust: none; margin-bottom: 1em; margin-left: 30px; margin-top: 0px"> <li \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; font-size-adjust: \
none; margin-bottom: 0.5em; margin-top: 0px; overflow-wrap: break-word"> 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).</li><li style="border-bottom-color: currentColor; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
font-size-adjust: none; margin-bottom: 0.5em; margin-top: 0px; overflow-wrap: \
break-word"> 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.</li><li \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; font-size-adjust: \
none; margin-bottom: 0px; margin-top: 0px; overflow-wrap: break-word"> 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).</li></ul> <span style="display: inline \
!important; background-color: rgb(255, 255, 255); color: rgb(36, 39, 41); \
font-family: Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif; font-size: 15px; \
font-size-adjust: none; line-height: 1.3; overflow-wrap: break-word"></span> <p \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; clear: both; color: \
rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; margin-bottom: 1em; \
margin-top: 0px"> A good example of an script where this behavior can be seen is: <a \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; color: \
var(--blue-700); cursor: pointer; font-size-adjust: none; margin-bottom: 0px; \
margin-top: 0px; text-decoration: underline" \
href="https://github.com/georgegach/crosshair/blob/master/cross.py" rel="nofollow \
noreferrer"> https://github.com/georgegach/crosshair/blob/master/cross.py</a></p>
<span style="display: inline !important; background-color: rgb(255, 255, 255); color: \
rgb(36, 39, 41); font-family: Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif; \
font-size: 15px; font-size-adjust: none; line-height: 1.3; overflow-wrap: \
break-word"></span> <p style="border-bottom-color: currentColor; border-left-color: \
currentColor; border-right-color: currentColor; border-top-color: currentColor; \
clear: both; color: rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; \
margin-bottom: 1em; margin-top: 0px"> Is there any option to make this PyQt5 window \
stay on top of absolutely everything, until stopped?</p> <p \
style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; clear: both; color: \
rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; margin-bottom: 1em; \
margin-top: 0px"> <br>
</p>
<p style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; clear: both; color: \
rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; margin-bottom: 1em; \
margin-top: 0px"> Thank you,</p>
<p style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; clear: both; color: \
rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; margin-bottom: 1em; \
margin-top: 0px"> <br>
</p>
<p style="border-bottom-color: currentColor; border-left-color: currentColor; \
border-right-color: currentColor; border-top-color: currentColor; clear: both; color: \
rgb(36, 39, 41); font-size: 100%; font-size-adjust: none; margin-bottom: 1em; \
margin-top: 0px"> Alberto Paris<br>
</p>
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; \
font-size: 12pt;"> <br>
</div>
<div id="Signature">
<div>
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; \
background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif"> \
&nbsp;</div> </div>
</div>
</div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic