-
-
Save ArtemBernatskyy/13d7ac1060b0677eb0d9590650b244dd to your computer and use it in GitHub Desktop.
Simulate desktop activity
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 python | |
import sys | |
import pyautogui | |
from datetime import datetime, timedelta | |
def move_rel(dx, dy, dur): | |
pyautogui.moveRel(dx, dy, dur, pyautogui.easeInQuad) | |
def square(side, dur): | |
move_rel(side, 0, dur) | |
move_rel(0, side, dur) | |
move_rel(-side, 0, dur) | |
move_rel(0, -side, dur) | |
def cycle_win(): | |
pyautogui.keyDown('alt') | |
pyautogui.keyDown('shift') | |
pyautogui.keyDown('tab') | |
pyautogui.keyUp('tab') | |
pyautogui.keyUp('shift') | |
pyautogui.keyUp('alt') | |
def activity(): | |
square(600, 1) | |
for _ in range(5): | |
cycle_win() | |
def main(): | |
dur_min = 1 | |
if len(sys.argv) >= 2: | |
dur_min = int(sys.argv[1]) | |
until = datetime.now() + timedelta(minutes=dur_min) | |
while datetime.now() < until: | |
activity() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment