Skip to content

Instantly share code, notes, and snippets.

@pedrohenriquebr
Created December 28, 2025 00:40
Show Gist options
  • Select an option

  • Save pedrohenriquebr/ae70067ec5b2d0f74e39871888bf4505 to your computer and use it in GitHub Desktop.

Select an option

Save pedrohenriquebr/ae70067ec5b2d0f74e39871888bf4505 to your computer and use it in GitHub Desktop.
Hold screen on
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