Simplify random coordinate setting

This commit is contained in:
coolneng 2020-07-28 15:31:55 +02:00
parent 09e28e744e
commit 00fe7d12b7
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 5 additions and 6 deletions

View File

@ -1,21 +1,20 @@
from mouse import get_position, move from mouse import get_position, move
from random import randint from secrets import randbelow
from time import sleep from time import sleep
def erratic_movement(screen_width, screen_height): def erratic_movement(screen_width, screen_height):
x, y = get_position()
move( move(
x + randint(-100, 100) % screen_width, y + randint(-100, 100) % screen_height, randbelow(screen_width), randbelow(screen_height),
) )
def main(): def main():
screen_width = 1920 screen_width = 800
screen_height = 1080 screen_height = 600
while True: while True:
erratic_movement(screen_width, screen_height) erratic_movement(screen_width, screen_height)
sleep(randint(2, 10)) sleep(randbelow(10))
if __name__ == "__main__": if __name__ == "__main__":