From e8d6bd2e87294f1c58f7d3b136c772e7e01496a8 Mon Sep 17 00:00:00 2001 From: edef Date: Wed, 23 Oct 2024 02:51:35 +0000 Subject: [PATCH] Use Return rather than Linefeed when typing with xdotool Most applications don't recognise the Linefeed key, so we replace \n with \r, which sends the Return key instead. --- computer-use-demo/computer_use_demo/tools/computer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/computer-use-demo/computer_use_demo/tools/computer.py b/computer-use-demo/computer_use_demo/tools/computer.py index 0b5c77db..7f99c75c 100644 --- a/computer-use-demo/computer_use_demo/tools/computer.py +++ b/computer-use-demo/computer_use_demo/tools/computer.py @@ -146,7 +146,7 @@ async def __call__( return await self.shell(f"{self.xdotool} key -- {text}") elif action == "type": results: list[ToolResult] = [] - for chunk in chunks(text, TYPING_GROUP_SIZE): + for chunk in chunks(text.replace('\n', '\r'), TYPING_GROUP_SIZE): cmd = f"{self.xdotool} type --delay {TYPING_DELAY_MS} -- {shlex.quote(chunk)}" results.append(await self.shell(cmd, take_screenshot=False)) screenshot_base64 = (await self.screenshot()).base64_image