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 threading
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 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 PIL import ImageGrab # type: ignore
@ -17,28 +33,47 @@ def screenshot_to_base64(screenshot: bytes) -> str:
return base64.b64encode(screenshot).decode('utf-8')
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."""
# Create a top-level window without decorations
root = tk.Tk()
root.overrideredirect(True)
root.attributes('-topmost', True)
# Semi-transparent window and disable to allow click-through
root.attributes('-alpha', 0.5)
try:
root.attributes('-disabled', True)
except Exception:
pass
# Position and size
half = size // 2
root.geometry(f"{size}x{size}+{x-half}+{y-half}")
# Draw circle on canvas
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()
# Keep displayed for duration seconds
time.sleep(duration)
root.destroy()
# """Display a red circle at (x, y) for the given duration."""
# """Try PyQt5 overlay first, else fallback to tkinter."""
# half = size // 2
# if PYQT_AVAILABLE:
# # Setup QApplication
# app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
# # Frameless, transparent, click-through window
# w = QtWidgets.QWidget()
# flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool
# w.setWindowFlags(flags)
# w.setAttribute(QtCore.Qt.WA_TranslucentBackground)
# w.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
# w.setGeometry(x-half, y-half, size, size)
# # Draw circle
# pixmap = QtGui.QPixmap(size, size)
# pixmap.fill(QtCore.Qt.transparent)
# painter = QtGui.QPainter(pixmap)
# pen = QtGui.QPen(QtGui.QColor('red'), 4)
# painter.setPen(pen)
# painter.drawEllipse(2, 2, size-4, size-4)
# painter.end()
# 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:
"""Presses mouse buttons at the given position."""