tempfix: remove mouse overlay

This commit is contained in:
Showdown76 2025-05-19 12:51:59 +02:00
parent 1925a77d85
commit a4e078bc19

View File

@ -1,7 +1,23 @@
import pyautogui import pyautogui
import threading import threading
import time, io, base64 import time, io, base64
import sys
# Try PyQt5 for transparent, click-through overlay
try:
from PyQt5 import QtWidgets, QtCore, QtGui
PYQT_AVAILABLE = True
except ImportError:
import tkinter as tk import tkinter as tk
import sys
if sys.platform == 'darwin':
try:
from AppKit import NSApplication, NSPanel, NSColor, NSBezierPath, NSView, NSWindowStyleMaskBorderless, NSBackingStoreBuffered, NSStatusWindowLevel, NSWindowCollectionBehaviorCanJoinAllSpaces
COCOA_AVAILABLE = True
except ImportError:
COCOA_AVAILABLE = False
else:
COCOA_AVAILABLE = False
PYQT_AVAILABLE = False
from objects.inputs import MouseInput, KeyboardInput, ButtonType from objects.inputs import MouseInput, KeyboardInput, ButtonType
from PIL import ImageGrab # type: ignore from PIL import ImageGrab # type: ignore
@ -17,28 +33,47 @@ def screenshot_to_base64(screenshot: bytes) -> str:
return base64.b64encode(screenshot).decode('utf-8') return base64.b64encode(screenshot).decode('utf-8')
def show_click_indicator(x: int, y: int, duration: float = 2.0, size: int = 50) -> None: def show_click_indicator(x: int, y: int, duration: float = 2.0, size: int = 50) -> None:
"""Display a red circle at (x, y) for the given duration.""" # """Display a red circle at (x, y) for the given duration."""
# Create a top-level window without decorations # """Try PyQt5 overlay first, else fallback to tkinter."""
root = tk.Tk() # half = size // 2
root.overrideredirect(True) # if PYQT_AVAILABLE:
root.attributes('-topmost', True) # # Setup QApplication
# Semi-transparent window and disable to allow click-through # app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
root.attributes('-alpha', 0.5) # # Frameless, transparent, click-through window
try: # w = QtWidgets.QWidget()
root.attributes('-disabled', True) # flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool
except Exception: # w.setWindowFlags(flags)
pass # w.setAttribute(QtCore.Qt.WA_TranslucentBackground)
# Position and size # w.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
half = size // 2 # w.setGeometry(x-half, y-half, size, size)
root.geometry(f"{size}x{size}+{x-half}+{y-half}") # # Draw circle
# Draw circle on canvas # pixmap = QtGui.QPixmap(size, size)
canvas = tk.Canvas(root, width=size, height=size, highlightthickness=0, bg='white') # pixmap.fill(QtCore.Qt.transparent)
canvas.pack() # painter = QtGui.QPainter(pixmap)
canvas.create_oval(2, 2, size-2, size-2, outline='red', width=4) # pen = QtGui.QPen(QtGui.QColor('red'), 4)
root.update() # painter.setPen(pen)
# Keep displayed for duration seconds # painter.drawEllipse(2, 2, size-4, size-4)
time.sleep(duration) # painter.end()
root.destroy() # label = QtWidgets.QLabel(w)
# label.setPixmap(pixmap)
# w.show()
# app.processEvents()
# time.sleep(duration)
# w.close()
# else:
# # Fallback tkinter overlay (may intercept clicks)
# root = tk.Tk()
# root.overrideredirect(True)
# root.attributes('-topmost', True)
# root.attributes('-alpha', 0.5)
# root.geometry(f"{size}x{size}+{x-half}+{y-half}")
# canvas = tk.Canvas(root, width=size, height=size, highlightthickness=0, bg='white')
# canvas.pack()
# canvas.create_oval(2, 2, size-2, size-2, outline='red', width=4)
# root.update()
# time.sleep(duration)
# root.destroy()
pass
def press_mouse(mouse_input: MouseInput) -> None: def press_mouse(mouse_input: MouseInput) -> None:
"""Presses mouse buttons at the given position.""" """Presses mouse buttons at the given position."""