Skip to content

Commit a110a0f

Browse files
committed
add pyqt overlay
1 parent 4bba8b3 commit a110a0f

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# fullscreen in game overlay / on screen display software
1+
# fullscreen in game overlay / on screen display software for Microsoft Windows
22
- Playclaw can draw these types of overlay : text, web browser, web cam, hardware stats etc...
33
Text can be read from file, at 0.5 seconds interval, supports webcam input from obs virtual cam plugin.
44
SDK for version 6 - https://github.com/CyberDemonLord/playclaw6-sdk
@@ -16,7 +16,6 @@ crosshair repo - https://github.com/LouisTakePILLz/reshade-xhair
1616

1717
- Overwolf only for whitelisted apps
1818
- Mangohud [not yet](https://github.com/flightlessmango/MangoHud/issues/222) working on windows
19-
2019
# Dual monitor/screen/display based overlay
2120
OBS Studio supports sending preview to another monitor, so you can grab fullscreen application,
2221
typically a game, compose a scene with overlays, then send it RMB > Fullscreen project > Some monitor.
@@ -32,3 +31,6 @@ To maximise performance of preview - set in Settings>Video>FPS>Integral value to
3231
- `/cheatengine` - Output health value to txt file repeatedly and then using OBS scripting to set level of opacity filter according to HP value,[`cheatengine`](cheatengine/cheatengine.md)
3332
- `pygame_overlay.py` - overlay for game OpenSpades running in windowed mode
3433
- `overlay.ahk` - ahk script to set any window to be non clickable
34+
- `x11_pyqt_overlay.py` - creates overlay from any window on X11.
35+
# See also
36+
[`transparent fullscreen on-top click-through WebKit web view, for making cool desktop HUDs `](https://github.com/anko/hudkit)

x11_pyqt_overlay.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import sys
2+
from ast import literal_eval
3+
from threading import Thread
4+
from PyQt5.QtGui import QWindow
5+
from PyQt5.QtCore import Qt, QTimer
6+
from PyQt5.QtWidgets import QWidget, QApplication, QHBoxLayout
7+
from types import SimpleNamespace as _G
8+
9+
G = _G()
10+
11+
G.running = False
12+
G.done = False
13+
__version__ = "0.1.0"
14+
15+
16+
def event_loop():
17+
print("commands: start - starts click through, exit - gracefully stop")
18+
try:
19+
while True:
20+
data = input(">").lower()
21+
if data == "start":
22+
print("start")
23+
G.running = True
24+
25+
if data == "exit":
26+
sys.exit(0)
27+
print("exit")
28+
if "opacity" in data:
29+
print("to be implemented")
30+
31+
except (KeyboardInterrupt, EOFError):
32+
sys.exit(0)
33+
34+
35+
class Main(QWidget):
36+
def __init__(self, hwnd, parent=None):
37+
QWidget.__init__(self, parent)
38+
window = QWindow.fromWinId(hwnd)
39+
self.container = self.createWindowContainer(window)
40+
self.setGeometry(100, 100, 1024, 768)
41+
# layout = QVBoxLayout(self)
42+
layout = QHBoxLayout(self)
43+
layout.addWidget(self.container)
44+
self.setLayout(layout)
45+
self.show()
46+
self.launch_timer()
47+
48+
def launch_timer(self):
49+
self.timer = QTimer()
50+
self.timer.setInterval(15)
51+
self.timer.timeout.connect(self.interal_event_loop)
52+
self.timer.start()
53+
54+
def interal_event_loop(self):
55+
if G.running and not G.done:
56+
self.make_overlay()
57+
G.done = True
58+
59+
def make_overlay(self):
60+
print("overlay created")
61+
self.setWindowFlags(
62+
Qt.Window
63+
| Qt.CustomizeWindowHint
64+
| Qt.WindowStaysOnTopHint
65+
| Qt.FramelessWindowHint
66+
| Qt.X11BypassWindowManagerHint
67+
| Qt.WindowTransparentForInput
68+
)
69+
self.show()
70+
71+
72+
if __name__ == "__main__":
73+
print("You should provide window id, get it using xwininfo")
74+
75+
Thread(target=event_loop).start()
76+
app = QApplication(sys.argv)
77+
win = Main(int(literal_eval(sys.argv[1])))
78+
win.setWindowTitle("Window container")
79+
sys.exit(app.exec_())

0 commit comments

Comments
 (0)