Skip to content

Commit be9c08c

Browse files
Added delay after moving the mouse
1 parent a3b98fd commit be9c08c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

botcity/core/bot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ def mouse_move(self, x, y):
652652
653653
"""
654654
self._mouse_controller.position = (x, y)
655+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
655656

656657
def click_at(self, x, y):
657658
"""
@@ -778,6 +779,7 @@ def scroll_down(self, clicks):
778779
clicks (int): Number of times to scroll down.
779780
"""
780781
self._mouse_controller.scroll(0, -1 * clicks)
782+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
781783

782784
def scroll_up(self, clicks):
783785
"""
@@ -787,6 +789,7 @@ def scroll_up(self, clicks):
787789
clicks (int): Number of times to scroll up.
788790
"""
789791
self._mouse_controller.scroll(0, clicks)
792+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
790793

791794
@only_if_element
792795
def move(self):
@@ -795,6 +798,7 @@ def move(self):
795798
"""
796799
x, y = self.state.center()
797800
self._mouse_controller.position = (x, y)
801+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
798802

799803
def move_relative(self, x, y):
800804
"""
@@ -808,6 +812,7 @@ def move_relative(self, x, y):
808812
x = self.get_last_x() + x
809813
y = self.get_last_y() + y
810814
self._mouse_controller.position = (x, y)
815+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
811816

812817
def move_random(self, range_x, range_y):
813818
"""
@@ -821,6 +826,7 @@ def move_random(self, range_x, range_y):
821826
x = int(random.random() * range_x)
822827
y = int(random.random() * range_y)
823828
self._mouse_controller.position = (x, y)
829+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
824830

825831
@only_if_element
826832
def right_click(self, wait_after=config.DEFAULT_SLEEP_AFTER_ACTION, *,

botcity/core/input_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def _mouse_click(mouse_controller: Controller, x: int, y: int, clicks=1, interva
7070
The mouse button has to be one of these values: {list(mouse_map.keys())}''')
7171

7272
mouse_controller.position = (x, y)
73+
time.sleep(0.1)
7374
for i in range(clicks):
7475
mouse_controller.click(button=mouse_button, count=1)
7576
time.sleep(interval_between_clicks / 1000.0)

0 commit comments

Comments
 (0)