Skip to content

Commit

Permalink
Use Return rather than Linefeed when typing with xdotool
Browse files Browse the repository at this point in the history
Most applications don't recognise the Linefeed key, so we replace \n
with \r, which sends the Return key instead.
  • Loading branch information
edef1c committed Oct 23, 2024
1 parent 4acbe40 commit e8d6bd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion computer-use-demo/computer_use_demo/tools/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8d6bd2

Please sign in to comment.