From 334ae7a10382463486c67af2024b291282eaaefc Mon Sep 17 00:00:00 2001 From: OSRS-B0b <131605729+OSRS-B0b@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:49:35 -0500 Subject: [PATCH 1/6] Add double click function to mouse.py --- src/utilities/mouse.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utilities/mouse.py b/src/utilities/mouse.py index 206d1bec..f003a4ad 100644 --- a/src/utilities/mouse.py +++ b/src/utilities/mouse.py @@ -97,6 +97,18 @@ def click(self, button="left", force_delay=False, check_red_click=False) -> tupl pag.mouseUp(button=button) if check_red_click: return self.__is_red_click(mouse_pos_before, mouse_pos_after) + def double_click(self, force_delay=False): + """ + Double left-clicks on the current mouse position with a small delay between clicks. + Args: + with_delay: whether to add a random delay between mouse down and mouse up (default True). + """ + self.click(force_delay=force_delay) + LOWER_BOUND_WAIT_INTERVAL = 0.07 # Milliseconds + UPPER_BOUND_WAIT_INTERVAL = 0.15 # Milliseconds + AVERAGE_WAIT_INTERVAL = 0.09 # Milliseconds + time.sleep(truncated_normal_sample(LOWER_BOUND_WAIT_INTERVAL, UPPER_BOUND_WAIT_INTERVAL, AVERAGE_WAIT_INTERVAL)) + self.click(force_delay=force_delay) def right_click(self, force_delay=False): """ From fdcfa0a1c162356450b7af7ff387b7e8a01069f9 Mon Sep 17 00:00:00 2001 From: OSRS-B0b <131605729+OSRS-B0b@users.noreply.github.com> Date: Sun, 23 Apr 2023 11:04:12 -0500 Subject: [PATCH 2/6] Make delay in mouse.double_click optional --- src/utilities/mouse.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utilities/mouse.py b/src/utilities/mouse.py index f003a4ad..7077a57b 100644 --- a/src/utilities/mouse.py +++ b/src/utilities/mouse.py @@ -104,10 +104,11 @@ def double_click(self, force_delay=False): with_delay: whether to add a random delay between mouse down and mouse up (default True). """ self.click(force_delay=force_delay) - LOWER_BOUND_WAIT_INTERVAL = 0.07 # Milliseconds - UPPER_BOUND_WAIT_INTERVAL = 0.15 # Milliseconds - AVERAGE_WAIT_INTERVAL = 0.09 # Milliseconds - time.sleep(truncated_normal_sample(LOWER_BOUND_WAIT_INTERVAL, UPPER_BOUND_WAIT_INTERVAL, AVERAGE_WAIT_INTERVAL)) + if force_delay or self.click_delay: + LOWER_BOUND_WAIT_INTERVAL = 0.07 # Milliseconds + UPPER_BOUND_WAIT_INTERVAL = 0.15 # Milliseconds + AVERAGE_WAIT_INTERVAL = 0.09 # Milliseconds + time.sleep(truncated_normal_sample(LOWER_BOUND_WAIT_INTERVAL, UPPER_BOUND_WAIT_INTERVAL, AVERAGE_WAIT_INTERVAL)) self.click(force_delay=force_delay) def right_click(self, force_delay=False): From 535b97d07e144ce39d75fc6c443334a4fa692f9c Mon Sep 17 00:00:00 2001 From: OSRS-B0b <131605729+OSRS-B0b@users.noreply.github.com> Date: Sun, 23 Apr 2023 11:06:58 -0500 Subject: [PATCH 3/6] Update mouse.py --- src/utilities/mouse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/mouse.py b/src/utilities/mouse.py index 7077a57b..4b30959f 100644 --- a/src/utilities/mouse.py +++ b/src/utilities/mouse.py @@ -101,7 +101,7 @@ def double_click(self, force_delay=False): """ Double left-clicks on the current mouse position with a small delay between clicks. Args: - with_delay: whether to add a random delay between mouse down and mouse up (default True). + with_delay: whether to add a random delay between each click (default True). This delay is on top of any additional delay in click() """ self.click(force_delay=force_delay) if force_delay or self.click_delay: From 6dc1fcaafe6f789e80f34ba7777a70270155d755 Mon Sep 17 00:00:00 2001 From: OSRS-B0b <131605729+OSRS-B0b@users.noreply.github.com> Date: Sat, 13 May 2023 21:36:15 -0500 Subject: [PATCH 4/6] fix move_camera where one degree = 0 --- src/model/bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/model/bot.py b/src/model/bot.py index 48190351..c664cec2 100644 --- a/src/model/bot.py +++ b/src/model/bot.py @@ -489,6 +489,13 @@ def keypress(direction, duration): time.sleep(duration) pag.keyUp(direction) + # if a single direction is 0 avoid pressing that key for any length of time so we don't nudge the camera over + if vertical == 0: + keypress(direction_h, sleep_h) + return + elif horizontal == 0: + keypress(direction_v, sleep_v) + thread_h = threading.Thread(target=keypress, args=(direction_h, sleep_h), daemon=True) thread_v = threading.Thread(target=keypress, args=(direction_v, sleep_v), daemon=True) delay = rd.fancy_normal_sample(0, max(sleep_h, sleep_v)) From 516bf2fd4325235d74b652aca218157fcaeba69c Mon Sep 17 00:00:00 2001 From: OSRS-B0b <131605729+OSRS-B0b@users.noreply.github.com> Date: Sat, 13 May 2023 21:41:26 -0500 Subject: [PATCH 5/6] too lazy to remove these changes the right way lol --- src/utilities/mouse.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/utilities/mouse.py b/src/utilities/mouse.py index 4b30959f..206d1bec 100644 --- a/src/utilities/mouse.py +++ b/src/utilities/mouse.py @@ -97,19 +97,6 @@ def click(self, button="left", force_delay=False, check_red_click=False) -> tupl pag.mouseUp(button=button) if check_red_click: return self.__is_red_click(mouse_pos_before, mouse_pos_after) - def double_click(self, force_delay=False): - """ - Double left-clicks on the current mouse position with a small delay between clicks. - Args: - with_delay: whether to add a random delay between each click (default True). This delay is on top of any additional delay in click() - """ - self.click(force_delay=force_delay) - if force_delay or self.click_delay: - LOWER_BOUND_WAIT_INTERVAL = 0.07 # Milliseconds - UPPER_BOUND_WAIT_INTERVAL = 0.15 # Milliseconds - AVERAGE_WAIT_INTERVAL = 0.09 # Milliseconds - time.sleep(truncated_normal_sample(LOWER_BOUND_WAIT_INTERVAL, UPPER_BOUND_WAIT_INTERVAL, AVERAGE_WAIT_INTERVAL)) - self.click(force_delay=force_delay) def right_click(self, force_delay=False): """ From d6fc3017ce6553cae624e7c1071125e2e4237be0 Mon Sep 17 00:00:00 2001 From: OSRS-B0b <131605729+OSRS-B0b@users.noreply.github.com> Date: Sat, 13 May 2023 21:53:26 -0500 Subject: [PATCH 6/6] return correctly --- src/model/bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/model/bot.py b/src/model/bot.py index c664cec2..c1c99e76 100644 --- a/src/model/bot.py +++ b/src/model/bot.py @@ -495,6 +495,7 @@ def keypress(direction, duration): return elif horizontal == 0: keypress(direction_v, sleep_v) + return thread_h = threading.Thread(target=keypress, args=(direction_h, sleep_h), daemon=True) thread_v = threading.Thread(target=keypress, args=(direction_v, sleep_v), daemon=True)