Compare commits
	
		
			2 Commits
		
	
	
		
			84d65cb505
			...
			66330bfc73
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 66330bfc73 | |||
| 41f7d0e210 | 
@@ -1,18 +1,47 @@
 | 
			
		||||
import pyautogui
 | 
			
		||||
import threading
 | 
			
		||||
import time
 | 
			
		||||
import tkinter as tk
 | 
			
		||||
from objects.inputs import MouseInput, KeyboardInput, ButtonType
 | 
			
		||||
 | 
			
		||||
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()
 | 
			
		||||
 | 
			
		||||
def press_mouse(mouse_input: MouseInput) -> None:
 | 
			
		||||
    """Presses mouse buttons at the given position."""
 | 
			
		||||
    x, y = mouse_input.x, mouse_input.y
 | 
			
		||||
    button = mouse_input.click_type
 | 
			
		||||
    if button == ButtonType.LEFT:
 | 
			
		||||
    if button == "left":
 | 
			
		||||
        pyautogui.click(x, y, button='left')
 | 
			
		||||
    elif button == ButtonType.DOUBLE_LEFT:
 | 
			
		||||
    elif button == "double_left":
 | 
			
		||||
        pyautogui.doubleClick(x, y)
 | 
			
		||||
    elif button == ButtonType.RIGHT:
 | 
			
		||||
    elif button == "right":
 | 
			
		||||
        pyautogui.click(x, y, button='right')
 | 
			
		||||
    elif button == ButtonType.MIDDLE:
 | 
			
		||||
    elif button == "middle":
 | 
			
		||||
        pyautogui.click(x, y, button='middle')
 | 
			
		||||
    # Show red circle indicator at click position for 2 seconds
 | 
			
		||||
    threading.Thread(target=show_click_indicator, args=(x, y), daemon=True).start()
 | 
			
		||||
 | 
			
		||||
def press_keyboard(keyboard_input: KeyboardInput) -> None:
 | 
			
		||||
    """Types the given sequence of keys."""
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
									
									
									
									
								
							@@ -12,7 +12,7 @@ def main():
 | 
			
		||||
        model=os.getenv("OPENAI_MODEL", "gpt-4.1")
 | 
			
		||||
    )
 | 
			
		||||
    server = webserver.web.WebServerApp(aip)
 | 
			
		||||
    server.run()
 | 
			
		||||
    server.run(host="0.0.0.0", port=int(os.getenv("PORT", 5000)), debug=int(os.getenv("DEBUG", 0)) > 0)
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    main()
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ from flask import Flask, request, jsonify
 | 
			
		||||
import os, ai.processor
 | 
			
		||||
from dotenv import load_dotenv
 | 
			
		||||
import io
 | 
			
		||||
from PIL import ImageGrab
 | 
			
		||||
from PIL import ImageGrab # type: ignore
 | 
			
		||||
 | 
			
		||||
load_dotenv()
 | 
			
		||||
 | 
			
		||||
@@ -40,6 +40,7 @@ class WebServerApp:
 | 
			
		||||
                    img_data = None
 | 
			
		||||
            else:
 | 
			
		||||
                if 'host_screenshot' in data:
 | 
			
		||||
                    print('Taking screenshot...')
 | 
			
		||||
                    # take a screenshot right here
 | 
			
		||||
                    # capture the full screen
 | 
			
		||||
                    screenshot_img = ImageGrab.grab()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user