How to use the pyautogui.scroll 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
def test_scroll(self):
        # TODO - currently this just checks that scrolling doesn't result in an error.
        pyautogui.scroll(1)
        pyautogui.scroll(-1)
        pyautogui.hscroll(1)
        pyautogui.hscroll(-1)
        pyautogui.vscroll(1)
        pyautogui.vscroll(-1)
github deverlabs / grappe / worker-v2 / worker.py View on Github external
def mouseAction(self, action_type):
        if action_type == "scrollUp":
            return pyautogui.scroll(30)
        elif action_type == "scrollDown":
            return pyautogui.scroll(-30)
        else:
            return
github arsho / autolike / autolike / __init__.py View on Github external
}
    try:
        pt.moveTo(800,250)
        start = time.time()
        like_image = os.path.join(os.path.dirname(__file__), 'like.png')
        webbrowser.open(url)
        time.sleep(4)
        cnt_like = 0
        elapsed_time = 0
        while True:
            like_pos = pt.locateCenterOnScreen(like_image,grayscale = True)
            if like_pos != None:
                pt.click(like_pos[0], like_pos[1])
                pt.moveTo(800,250)
                cnt_like+=1
            pt.scroll(-400)
            time.sleep(4)    
            end = time.time()
            elapsed_time = end - start
            if elapsed_time > run_time:
                elapsed_time = str(int(elapsed_time))
                return_dict["status"] = "success"
                return_dict["message"] = "Method is called successfully."
                return_dict["like"] = cnt_like
                return_dict["url"] = url
                return_dict["time"] = elapsed_time                
                break
            elapsed_time = str(int(elapsed_time))
            return_dict["status"] = "success"
            return_dict["message"] = "Method is called successfully."
            return_dict["like"] = cnt_like
            return_dict["url"] = url
github deverlabs / grappe / worker / worker.py View on Github external
def mouseAction(self, action_type):
        if action_type == "scrollUp":
            return pyautogui.scroll(40)
        elif action_type == "scrollDown":
            return pyautogui.scroll(-40)
github sylwekb / AutoMama / visual / actions / gui.py View on Github external
def run(self):
        query_image = cv2.imread(self.path)

        time_start = time.time()
        for i in itertools.count(1):
            try:
                self.find_image(query_image, take_screenshot())
            except QueryImageNotFound:
                print(
                    f"\ttrying {i}. time, {self.path} is still not visible, scrolling..."
                )
                pyautogui.scroll(self.distance)

            else:
                print(
                    f"\t{self.path} is visible, took: {time.time() - time_start:.2f}s"
                )
                return

            if time.time() > time_start + self.timeout:
                raise TimeoutError(
                    f"{self.path} is still not visible after {self.timeout} timeout"
                )

            time.sleep(self.check_interval)
github mozilla / iris_firefox / iris / api / core.py View on Github external
def zoom_with_mouse_wheel(nr_of_times=1, zoom_type=None):
    """Zoom in/Zoom out using the mouse wheel

    :param nr_of_times: Number of times the 'zoom in'/'zoom out' action should take place
    :param zoom_type: Type of the zoom action('zoom in'/'zoom out') intended to perform
    :return: None
    """

    # move focus in the middle of the page to be able to use the scroll
    pyautogui.moveTo(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 2)
    for i in range(nr_of_times):
        if Settings.getOS() == Platform.MAC:
            pyautogui.keyDown('command')
        else:
            pyautogui.keyDown('ctrl')
        pyautogui.scroll(zoom_type)
        if Settings.getOS() == Platform.MAC:
            pyautogui.keyUp('command')
        else:
            pyautogui.keyUp('ctrl')
        time.sleep(0.5)
    pyautogui.moveTo(0, 0)
github SerpentAI / SerpentAI / serpent / input_controllers / pyautogui_input_controller.py View on Github external
def scroll(self, clicks=1, direction="DOWN", **kwargs):
        if ("force" in kwargs and kwargs["force"] is True) or self.game_is_focused:
            clicks = clicks * (1 if direction == "DOWN" else -1)
            pyautogui.scroll(clicks)
github chaosparrot / parrot.py / lib / modes / mode_browse.py View on Github external
mouseMoving = False
		if( self.detector.detect("click") ):
			click()
		elif( self.detector.detect("moving" ) ):
			mouseMoving = True
			if( self.mode != "precision" ):
				if( self.mode == "regular" ):
					press("f4")
				self.mode = "precision"
				self.centerXPos, self.centerYPos = pyautogui.position()
		elif( self.detector.detect("rightclick") ):
			click(button='right')
		elif( self.detector.detect("scroll_up") ):
			scroll( 150 )
		elif( self.detector.detect("scroll_down") ):
			scroll( -150 )
		elif( self.detector.detect( "exit" ) ):
			self.modeSwitcher.turnOnModeSwitch()
		elif( self.detector.detect( "special" ) ):
			quadrant = detect_mouse_quadrant( 3, 3 )
			if( quadrant == 1 ):
				hotkey('alt', 'left')
			elif( quadrant == 2 ):
				hotkey('ctrl', 't')
			elif( quadrant == 3 ):
				hotkey('ctrl', 'w')
			elif( quadrant > 3 ):
				self.modeSwitcher.turnOnModeSwitch()
			
		if( self.mode == "precision" or self.mode == "pause" ):
			if( mouseMoving == False ):
				self.mode = "pause"
github mozilla / iris_firefox / iris / api / core.py View on Github external
def scroll(clicks):
    pyautogui.scroll(clicks)