Skip to content

Commit

Permalink
Add Pressed Escape to Double Click
Browse files Browse the repository at this point in the history
I have no idea if this works. Well see :D
  • Loading branch information
Vinyzu committed Aug 16, 2024
1 parent 6856ac1 commit 480e039
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cdp_patches/input/async_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ async def double_click(
) -> None:
x, y = int(x), int(y)

await self.click(button=button, x=x, y=y, timeout=timeout, emulate_behaviour=emulate_behaviour)
await self.click(button=button, x=x, y=y, timeout=timeout, emulate_behaviour=emulate_behaviour, pressed="__double_click__")
if self.emulate_behaviour and emulate_behaviour:
await self._sleep_timeout(random.uniform(0.14, 0.21))
# await self._sleep_timeout(timeout=timeout)
await self.click(button=button, x=x, y=y, emulate_behaviour=False, timeout=timeout, pressed=pressed)
await self.click(button=button, x=x, y=y, emulate_behaviour=False, timeout=timeout, pressed="__double_click__")

self.last_x, self.last_y = x, y

Expand Down
6 changes: 6 additions & 0 deletions cdp_patches/input/os_base/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,20 @@ async def async_get_window(self, timeout: float = 1) -> WindowSpecification:
def down(self, button: Literal["left", "right", "middle"], x: int, y: int, pressed: str = "") -> None:
if not pressed:
pressed = button
if pressed == "__double_click__":
pressed = ""
self.ensure_window()
self.browser_window.press_mouse(button=button, pressed=pressed, coords=(int(x * self.scale_factor), int(y * self.scale_factor)))

def up(self, button: Literal["left", "right", "middle"], x: int, y: int, pressed: str = "") -> None:
if pressed == "__double_click__":
pressed = ""
self.ensure_window()
self.browser_window.release_mouse(button=button, pressed=pressed, coords=(int(x * self.scale_factor), int(y * self.scale_factor)))

def move(self, x: int, y: int, pressed: str = "") -> None:
if pressed == "__double_click__":
pressed = ""
self.ensure_window()
self.browser_window.move_mouse(coords=(int(x * self.scale_factor), int(y * self.scale_factor)), pressed=pressed)

Expand Down
4 changes: 2 additions & 2 deletions cdp_patches/input/sync_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ def double_click(
) -> None:
x, y = int(x), int(y)

self.click(button=button, x=x, y=y, timeout=timeout, emulate_behaviour=emulate_behaviour, pressed=pressed)
self.click(button=button, x=x, y=y, timeout=timeout, emulate_behaviour=emulate_behaviour, pressed="__double_click__")
if emulate_behaviour and self.emulate_behaviour:
self._sleep_timeout(random.uniform(0.14, 0.21))
# self._sleep_timeout(timeout=timeout)
self.click(button=button, x=x, y=y, emulate_behaviour=False, timeout=timeout, pressed=pressed)
self.click(button=button, x=x, y=y, emulate_behaviour=False, timeout=timeout, pressed="__double_click__")

self.last_x, self.last_y = x, y

Expand Down

0 comments on commit 480e039

Please sign in to comment.