0% found this document useful (0 votes)
6 views

Mouse Functions

The document provides a series of commands for the PyAutoGUI library, which is used for automating mouse and keyboard actions in Python. It includes functions for displaying alerts, getting mouse positions, dragging the mouse, clicking, scrolling, typing, and taking screenshots. Additionally, it covers methods for locating images on the screen and simulating keyboard shortcuts.

Uploaded by

noamd74
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Mouse Functions

The document provides a series of commands for the PyAutoGUI library, which is used for automating mouse and keyboard actions in Python. It includes functions for displaying alerts, getting mouse positions, dragging the mouse, clicking, scrolling, typing, and taking screenshots. Additionally, it covers methods for locating images on the screen and simulating keyboard shortcuts.

Uploaded by

noamd74
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

MOUSE

pyautogui.alert('This displays some text with an OK button.')

pyautogui.position() # current mouse x and y

pyautogui.onScreen(x, y) # True if x & y are within the screen.

pyautogui.PAUSE = 2.5 # Pause 2.5 s

pyautogui.dragTo(x, y, duration=num_seconds) # drag mouse to XY

pyautogui.dragRel(xOffset, yOffset, duration=num_seconds) # drag mouse relative to


its current position

pyautogui.click(x=moveToX, y=moveToY, clicks=num_of_clicks,


interval=secs_between_clicks, button='left') # The button keyword argument can be
'left', 'middle', or 'right'.

pyautogui.scroll(amount_to_scroll, x=moveToX, y=moveToY)

pyautogui.mouseDown(x=moveToX, y=moveToY, button='left')

pyautogui.mouseUp(x=moveToX, y=moveToY, button='left')

pyautogui.typewrite('Hello world!\n', interval=secs_between_keys) # useful for


entering text, newline is Enter

pyautogui.typewrite(['a', 'b', 'c', 'left', 'backspace', 'enter', 'f1'],


interval=secs_between_keys)

pyautogui.hotkey('ctrl', 'c') # ctrl-c to copy

pyautogui.hotkey('ctrl', 'v') # ctrl-v to paste

pyautogui.alert('This displays some text with an OK button.')

pyautogui.confirm('This displays text and has an OK and Cancel button.')

pyautogui.prompt('This lets the user type in a string and press OK.')

pyautogui.screenshot('foo.png') # returns a Pillow/PIL Image object, and saves it


to a file

pyautogui.locateOnScreen('looksLikeThis.png')

pyautogui.locateCenterOnScreen('looksLikeThis.png') # returns center x and y

You might also like