Created
December 28, 2025 00:40
-
-
Save pedrohenriquebr/ae70067ec5b2d0f74e39871888bf4505 to your computer and use it in GitHub Desktop.
Hold screen on
This file contains hidden or 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
| import pyautogui as pg | |
| screen_width, screen_height = pg.size() | |
| pg.FAILSAFE = True | |
| pg.PAUSE = 0.01 | |
| center_x, center_y = screen_width // 2, screen_height // 2 | |
| square_size = 200 | |
| def move_to(x, y): | |
| print(f'Moving to ({x}, {y})') | |
| pg.moveTo(x, y, duration=1.5) | |
| while True: | |
| print('Moving to center of the screen') | |
| move_to(center_x, center_y) | |
| print('Moving to top-left corner of the square') | |
| move_to(center_x - square_size // 2, center_y - square_size // 2) | |
| print('Moving to top-right corner of the square') | |
| move_to(center_x + square_size // 2, center_y - square_size // 2) | |
| print('Moving to bottom-right corner of the square') | |
| move_to(center_x + square_size // 2, center_y + square_size // 2) | |
| print('Moving to bottom-left corner of the square') | |
| move_to(center_x - square_size // 2, center_y + square_size // 2) | |
| print('Returning to center of the screen') | |
| move_to(center_x, center_y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment