mirror of
https://github.com/trycua/computer.git
synced 2026-05-04 22:21:45 -05:00
Added experiment flag for now
This commit is contained in:
@@ -97,6 +97,14 @@ class Diorama:
|
||||
await automation_handler.drag_to(x, y, duration=duration)
|
||||
if future:
|
||||
future.set_result(None)
|
||||
elif action in ["scroll_up", "scroll_down"]:
|
||||
clicks = args.get("clicks", 1)
|
||||
if action == "scroll_up":
|
||||
await automation_handler.scroll_up(clicks)
|
||||
else:
|
||||
await automation_handler.scroll_down(clicks)
|
||||
if future:
|
||||
future.set_result(None)
|
||||
# Keyboard actions
|
||||
elif action == "type_text":
|
||||
text = args.get("text")
|
||||
@@ -198,6 +206,12 @@ class Diorama:
|
||||
async def hotkey(self, keys):
|
||||
await self._send_cmd("hotkey", {"keys": list(keys)})
|
||||
|
||||
async def scroll_up(self, clicks: int = 1):
|
||||
await self._send_cmd("scroll_up", {"clicks": clicks})
|
||||
|
||||
async def scroll_down(self, clicks: int = 1):
|
||||
await self._send_cmd("scroll_down", {"clicks": clicks})
|
||||
|
||||
async def get_screen_size(self) -> dict[str, int]:
|
||||
if not self._scene_size:
|
||||
await self.screenshot()
|
||||
|
||||
@@ -4,10 +4,11 @@ import platform
|
||||
import inspect
|
||||
from computer_server.diorama.diorama import Diorama
|
||||
from computer_server.diorama.base import BaseDioramaHandler
|
||||
from typing import Optional
|
||||
|
||||
class MacOSDioramaHandler(BaseDioramaHandler):
|
||||
"""Handler for Diorama commands on macOS, using local diorama module."""
|
||||
async def diorama_cmd(self, action: str, arguments: dict = None) -> dict:
|
||||
async def diorama_cmd(self, action: str, arguments: Optional[dict] = None) -> dict:
|
||||
if platform.system().lower() != "darwin":
|
||||
return {"success": False, "error": "Diorama is only supported on macOS."}
|
||||
try:
|
||||
|
||||
@@ -55,7 +55,7 @@ class HandlerFactory:
|
||||
|
||||
if os_type == 'darwin':
|
||||
return MacOSAccessibilityHandler(), MacOSAutomationHandler(), MacOSDioramaHandler()
|
||||
else:
|
||||
elif os_type == 'linux':
|
||||
return LinuxAccessibilityHandler(), LinuxAutomationHandler(), BaseDioramaHandler()
|
||||
|
||||
else:
|
||||
raise NotImplementedError(f"OS '{os_type}' is not supported")
|
||||
Reference in New Issue
Block a user