Skip to content

Commit

Permalink
Hopefully the GH Runner will agree this time
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinyzu committed Aug 19, 2024
1 parent 709b745 commit 523eaa7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ cython_debug/
#.idea/
/.idea
/.vs

# AI Weights
*.pt
2 changes: 1 addition & 1 deletion cdp_patches/input/async_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async def double_click(

press_timeout = click_timeout = timeout or self.sleep_timeout
if self.emulate_behaviour and emulate_behaviour:
# click_timeout = random.uniform(0.14, 0.21)
click_timeout = random.uniform(0.14, 0.21)
self._base.move(x=x, y=y)

kwargs = _mk_kwargs(pressed)
Expand Down
34 changes: 13 additions & 21 deletions cdp_patches/input/os_base/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,37 +134,29 @@ def down(self, button: Literal["left", "right", "middle"], x: int, y: int, press
self.ensure_window()
self.browser_window.press_mouse(button=button, pressed=pressed, coords=(int(x * self.scale_factor), int(y * self.scale_factor)))

def double_click(self, button: Literal["left", "right", "middle"], x: int, y: int, pressed: str = "", press_timeout: float = 0.01, click_timeout: float = 0.05) -> None:
def double_click(self, button: Literal["left", "right", "middle"], x: int, y: int, pressed: str = "", press_timeout: float = 0.01, click_timeout: float = 0.15) -> None:
if not pressed:
pressed = button
flags, click_point = _calc_flags_and_coords(pressed, [x, y])

self.ensure_window()

if button.lower() == "left":
first_click = (win32defines.WM_LBUTTONDOWN, win32defines.WM_LBUTTONUP)
second_click = (win32defines.WM_LBUTTONDBLCLK, win32defines.WM_LBUTTONUP)
click = (win32defines.WM_LBUTTONDOWN, win32defines.WM_LBUTTONUP)
elif button.lower() == "right":
first_click = (win32defines.WM_RBUTTONDOWN, win32defines.WM_RBUTTONUP)
second_click = (win32defines.WM_RBUTTONDBLCLK, win32defines.WM_RBUTTONUP)
click = (win32defines.WM_RBUTTONDOWN, win32defines.WM_RBUTTONUP)
else:
first_click = (win32defines.WM_MBUTTONDOWN, win32defines.WM_MBUTTONUP)
second_click = (win32defines.WM_MBUTTONDBLCLK, win32defines.WM_MBUTTONUP)
click = (win32defines.WM_MBUTTONDOWN, win32defines.WM_MBUTTONUP)

# figure out the flags and pack coordinates
flags, click_point = _calc_flags_and_coords(pressed, [x, y])
for msg in first_click:
win32functions.PostMessage(self.browser_window, msg, win32structures.WPARAM(flags), win32structures.LPARAM(click_point))
time.sleep(press_timeout)
# wait until the thread can accept another message
win32functions.WaitGuiThreadIdle(self.browser_window.handle)

time.sleep(click_timeout)

for msg in second_click:
win32functions.PostMessage(self.browser_window, msg, win32structures.WPARAM(flags), win32structures.LPARAM(click_point))
time.sleep(press_timeout)
# wait until the thread can accept another message
win32functions.WaitGuiThreadIdle(self.browser_window.handle)
for i in range(2):
for msg in click:
win32functions.PostMessage(self.browser_window, msg, win32structures.WPARAM(flags), win32structures.LPARAM(click_point))
time.sleep(press_timeout)
# wait until the thread can accept another message
win32functions.WaitGuiThreadIdle(self.browser_window.handle)
if not i:
time.sleep(click_timeout)

def up(self, button: Literal["left", "right", "middle"], x: int, y: int, pressed: str = "") -> None:
self.ensure_window()
Expand Down
2 changes: 1 addition & 1 deletion cdp_patches/input/sync_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def double_click(

press_timeout = click_timeout = timeout or self.sleep_timeout
if self.emulate_behaviour and emulate_behaviour:
# click_timeout = random.uniform(0.14, 0.21)
click_timeout = random.uniform(0.14, 0.21)
self._base.move(x=x, y=y)

kwargs = _mk_kwargs(pressed)
Expand Down

0 comments on commit 523eaa7

Please sign in to comment.