Fixes for hotkey and claude scrolling

This commit is contained in:
Dillon DuPont
2025-06-04 15:50:02 -04:00
parent 3e6cb3465e
commit 3ab5b65a25
2 changed files with 13 additions and 9 deletions

View File

@@ -478,17 +478,11 @@ class ComputerTool(BaseComputerTool, BaseAnthropicTool):
if direction == "down":
# Scroll down (Page Down on macOS)
self.logger.info(f"Scrolling down, amount: {amount}")
# Use fn+down for page down on macOS
for _ in range(amount):
await self.computer.interface.hotkey("fn", "down")
await asyncio.sleep(0.1)
await self.computer.interface.scroll_down(amount)
else:
# Scroll up (Page Up on macOS)
self.logger.info(f"Scrolling up, amount: {amount}")
# Use fn+up for page up on macOS
for _ in range(amount):
await self.computer.interface.hotkey("fn", "up")
await asyncio.sleep(0.1)
await self.computer.interface.scroll_up(amount)
# Wait briefly for UI changes
await asyncio.sleep(0.5)

View File

@@ -87,7 +87,17 @@ class DioramaComputerInterface:
await self._send_cmd("press_key", {"key": key})
async def hotkey(self, *keys):
await self._send_cmd("hotkey", {"keys": list(keys)})
actual_keys = []
for key in keys:
if isinstance(key, Key):
actual_keys.append(key.value)
elif isinstance(key, str):
# Try to convert to enum if it matches a known key
key_or_enum = Key.from_string(key)
actual_keys.append(key_or_enum.value if isinstance(key_or_enum, Key) else key_or_enum)
else:
raise ValueError(f"Invalid key type: {type(key)}. Must be Key enum or string.")
await self._send_cmd("hotkey", {"keys": actual_keys})
async def to_screen_coordinates(self, x, y):
return await self._send_cmd("to_screen_coordinates", {"x": x, "y": y})