How to use the pyautogui.moveRel function in PyAutoGUI

To help you get started, we’ve selected a few PyAutoGUI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asweigart / pyautogui / tests / test_pyautogui.py View on Github external
# Passing a list instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel([42, 42])
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a tuple instead of separate x and y.
        desired -= P(42, 42)
        pyautogui.moveRel((-42, -42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a sequence-like object instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel(P(42, 42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)
github Serlopal / wow_fishing_bot / bot_grid.py View on Github external
def loot(self):
		nitems = 3
		loot_coords = [float(x) for x in self.UI.loot_coords_edit.edit.text().split(" ")]
		loot_delta = float(self.UI.loot_delta_edit.edit.text())
		for i in range(nitems):
			time.sleep(0.5)
			pyautogui.moveTo(x=self.frame[0] + (self.frame[2] - self.frame[0]) * loot_coords[0],
							 y=self.frame[1] + (self.frame[3] - self.frame[1]) * (loot_coords[1] + i * loot_delta),
							 duration=0.5)
			pyautogui.moveRel(4, 0, duration=0.05)
			pyautogui.moveRel(-4, 0, duration=0.05)
			pyautogui.click()
github Serlopal / wow_fishing_bot / bot_grid.py View on Github external
b = int(self.frame[1] + self.frame[3] * self.grid_frac_ver[1])
		c = int(self.frame[0] + self.frame[2] * self.grid_frac_hor[0])
		d = int(self.frame[0] + self.frame[2] * self.grid_frac_hor[1])

		for j in range(a, b, grid_step):
			if found:
				break
			for i in range(c, d, grid_step):
				precursor = win32gui.GetCursorInfo()[1]
				utils.move_mouse([i, j])
				time.sleep(0.02)
				postcursor = win32gui.GetCursorInfo()[1]
				if precursor != postcursor:
					found = True
					j += int(self.frame[2] / 100)
					pyautogui.moveRel(0, int(self.frame[2] / 100), duration=0.05)

					self.UI.log_viewer.emitter.emit("Found bait at coordinates {0} , {1}".format(i, j))

					bait_coords = [i, j]
					break
		if bait_coords is not None:
			self.watch_bait(bait_coords)

		self.tries += 1
		self.UI.tries_count_label.text_emitter.emit("{} tries".format(str(self.tries)))
		self.jump()
github TREE-Ind / desktop-control / __init__.py View on Github external
def handle_relative_mouse_move_intent(self, message):
        if message.data.get("small"):
            if message.data.get("down"):
                move_down = self.sm_move_amount
                pyautogui.moveRel(0, move_down)
            if message.data.get("up"):
                move_up = self.sm_move_amount * -1
                pyautogui.moveRel(0, move_up)
            if message.data.get("left"):
                move_left = self.sm_move_amount * -1
                pyautogui.moveRel(move_left, 0)
            if message.data.get("right"):
                move_right = self.sm_move_amount
                pyautogui.moveRel(move_right, 0)
        elif message.data.get("med"):
            if message.data.get("down"):
                move_down = self.med_move_amount
                pyautogui.moveRel(0, move_down)
            if message.data.get("up"):
                move_up = self.med_move_amount * -1
                pyautogui.moveRel(0, move_up)
github ValeWasTaken / Programming_Books / Automate_the_Boring_Stuff / Chapter_018 / Practice_Problems / Looking_Busy.py View on Github external
def anti_idle():
    while True:
        mouse_position = pyautogui.position()
        random_x = random.randint(-1,1)
        random_y = random.randint(-1,1)
        time.sleep(10)
        if pyautogui.position() == mouse_position:
            pyautogui.moveRel(random_x, random_y)
anti_idle()
github SerpentAI / SerpentAI / serpent / input_controllers / pyautogui_input_controller.py View on Github external
def move(self, x=None, y=None, duration=0.25, absolute=True, **kwargs):
        if ("force" in kwargs and kwargs["force"] is True) or self.game_is_focused:
            x += self.game.window_geometry["x_offset"]
            y += self.game.window_geometry["y_offset"]

            if absolute:
                pyautogui.moveTo(x=x, y=y, duration=duration)
            else:
                pyautogui.moveRel(xOffset=x, yOffset=y, duration=duration)
github TREE-Ind / desktop-control / __init__.py View on Github external
def handle_relative_mouse_move_intent(self, message):
        if message.data.get("small"):
            if message.data.get("down"):
                move_down = self.sm_move_amount
                pyautogui.moveRel(0, move_down)
            if message.data.get("up"):
                move_up = self.sm_move_amount * -1
                pyautogui.moveRel(0, move_up)
            if message.data.get("left"):
                move_left = self.sm_move_amount * -1
                pyautogui.moveRel(move_left, 0)
            if message.data.get("right"):
                move_right = self.sm_move_amount
                pyautogui.moveRel(move_right, 0)
        elif message.data.get("med"):
            if message.data.get("down"):
                move_down = self.med_move_amount
                pyautogui.moveRel(0, move_down)
            if message.data.get("up"):
                move_up = self.med_move_amount * -1
                pyautogui.moveRel(0, move_up)
        elif message.data.get("large"):
            if message.data.get("down"):
                move_down = self.lg_move_amount
github RobinCPC / CE264-Computer_Vision / gesture_hci.py View on Github external
cur_cmd = 0
        if self.cmd_switch:
            if self.last_cmds.count(count_defects) >= self.last_cmds.n_maj:
                cur_cmd = count_defects
                #print 'major command is ', cur_cmd
            else:
                cur_cmd = 0     # self.last_cmds.major()
        else:
            cur_cmd = count_defects
        
        # send mouse input event depend on hand gesture
        if cur_cmd == 1:
            str1 = '2, move mouse dx,dy = ' + str(d_x*3) + ', ' + str(d_y*3)
            cv2.putText(img_src, str1, (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
            if self.cmd_switch:
                pyautogui.moveRel(d_x*3, d_y*3)
                self.last_cmds.push(count_defects)
                #pyautogui.mouseDown(button='left')
                #pyautogui.moveRel(d_x, d_y)
            #else:
            #    pyautogui.mouseUp(button='left')
        elif cur_cmd == 2:
            cv2.putText(img_src, '3 Left (rotate)', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
            if self.cmd_switch:
                pyautogui.dragRel(d_x, d_y, button='left')
                self.last_cmds.push(count_defects)
                #pyautogui.scroll(d_y,pause=0.2) 
        elif cur_cmd == 3:
            cv2.putText(img_src, '4 middle (zoom)', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
            if self.cmd_switch:
                pyautogui.dragRel(d_x, d_y, button='middle')
                self.last_cmds.push(count_defects)
github Serlopal / wow_fishing_bot / bot_SIFT.py View on Github external
def loot(self):
		nitems = 3
		for i in range(nitems):
			time.sleep(1)
			pyautogui.moveTo(x=self.window[0] + (self.window[2] - self.window[0]) * self.UI.loot_coords[0],
							 y=self.window[1] + (self.window[3] - self.window[1]) * (self.UI.loot_coords[1] + i * self.UI.loot_coords_delta),
							 duration=1)
			pyautogui.moveRel(4, 0, duration=0.2)
			pyautogui.moveRel(-4, 0, duration=0.2)
			pyautogui.click()
github ThePianoDentist / dotabots-ml-tools / run.py View on Github external
def single_log_line(cls, log_string):
        cls.delay(PressKey, 0x27)
        ReleaseKey(0x27)
        cls.delay(pa.typewrite, log_string)
        cls.delay(cls.click_pic, 'submit.png')  # Pressing enter doesnt seem to work here?
        cls.delay(PressKey, 0x27)
        ReleaseKey(0x27)
        pa.moveRel(25, 25)  # Cannot recognise submit button if cursor still over it