MCPcopy Create free account
hub / github.com/e2b-dev/desktop / get_cursor_position

Method get_cursor_position

packages/python-sdk/e2b_desktop/main.py:417–436  ·  view source on GitHub ↗

Get the current cursor position. :return: A tuple with the x and y coordinates :raises RuntimeError: If the cursor position cannot be determined

(self)

Source from the content-addressed store, hash-verified

415 self.commands.run(f"xdotool mouseup {MOUSE_BUTTONS[button]}")
416
417 def get_cursor_position(self) -> tuple[int, int]:
418 """
419 Get the current cursor position.
420
421 :return: A tuple with the x and y coordinates
422 :raises RuntimeError: If the cursor position cannot be determined
423 """
424 result = self.commands.run("xdotool getmouselocation")
425
426 groups = re_search(r"x:(\d+)\s+y:(\d+)", result.stdout)
427 if not groups:
428 raise RuntimeError(
429 f"Failed to parse cursor position from output: {result.stdout}"
430 )
431
432 x, y = groups.group(1), groups.group(2)
433 if not x or not y:
434 raise RuntimeError(f"Invalid cursor position values: x={x}, y={y}")
435
436 return int(x), int(y)
437
438 def get_screen_size(self) -> tuple[int, int]:
439 """

Callers 3

mainFunction · 0.80
test_right_clickFunction · 0.80
test_get_cursor_positionFunction · 0.80

Calls

no outgoing calls

Tested by 2

test_right_clickFunction · 0.64
test_get_cursor_positionFunction · 0.64