Skip to content

Instantly share code, notes, and snippets.

@jabbalaci
Created October 22, 2023 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabbalaci/2cdf7628064f5c9c27c7ba061d8911b9 to your computer and use it in GitHub Desktop.
Save jabbalaci/2cdf7628064f5c9c27c7ba061d8911b9 to your computer and use it in GitHub Desktop.
Automatically perform mouse operations with PyAutoGUI
#!/usr/bin/env python3
import time
import pyautogui
# where to click on the screen
X, Y = 1079, 481
# How many times to click.
# Start with a smaller value, and if it works,
# you can increase this value.
CLICKS = 10
def wait(duration=0.5):
time.sleep(duration)
def left_click():
pyautogui.click()
def countdown(n):
while n > 0:
print(n)
wait(1)
n -= 1
def main():
print("You have 3 seconds to switch to the browser!")
countdown(3)
pyautogui.moveTo(X, Y)
for i in range(CLICKS):
left_click()
wait(0.05)
##############################################################################
if __name__ == "__main__":
main()
@jabbalaci
Copy link
Author

jabbalaci commented Oct 22, 2023

This script belongs to this video: https://www.youtube.com/watch?v=yAcLrAlFrDg (in Hungarian).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment