Created
October 22, 2023 13:53
-
-
Save jabbalaci/2cdf7628064f5c9c27c7ba061d8911b9 to your computer and use it in GitHub Desktop.
Automatically perform mouse operations with PyAutoGUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script belongs to this video: https://www.youtube.com/watch?v=yAcLrAlFrDg (in Hungarian).