-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverlay.py
More file actions
64 lines (57 loc) · 1.91 KB
/
Copy pathoverlay.py
File metadata and controls
64 lines (57 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sys
from PyQt5 import QtGui, QtCore, uic
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtGui import QPainter, QBrush, QPen
from PyQt5.QtCore import Qt, QRect
import d3dshot
import PIL
import numpy
d = d3dshot.create(capture_output="numpy")
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowFlags(
QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.FramelessWindowHint |
QtCore.Qt.X11BypassWindowManagerHint
)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setGeometry(
QtWidgets.QStyle.alignedRect(
QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
QtCore.QSize(2560 , 1440),
QtWidgets.qApp.desktop().availableGeometry()
))
self.initUI()
def initUI(self):
self.rects = []
def mousePressEvent(self, event):
QtWidgets.qApp.quit()
def paintEvent(self, event):
painter = QPainter(self)
painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine))
#painter.setBrush(QBrush(Qt.red, Qt.SolidPattern))
#painter.setBrush(QBrush(Qt.green, Qt.DiagCrossPattern))
self.findHotSpots()
for rect in self.rects:
painter.drawRect(rect)
self.update()
def findHotSpots(self):
try:
im = d.screenshot()
c = (200, 0, 0)
indices = numpy.where(numpy.all(im == c, axis=-1))
coords = zip(indices[0], indices[1])
self.rects = []
for fpixels in coords:
x = fpixels[0]
y = fpixels[1]
self.rects.append(QRect(y-3,x+17,5,5))
except Exception as e:
print(e)
if __name__ == '__main__':
app = QApplication(sys.argv)
mywindow = MainWindow()
mywindow.show()
app.exec_()