Skip to content

Instantly share code, notes, and snippets.

@kotoripiyopiyo
Created June 18, 2021 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotoripiyopiyo/0b16460e3b30a2137c35615a1c26a72e to your computer and use it in GitHub Desktop.
Save kotoripiyopiyo/0b16460e3b30a2137c35615a1c26a72e to your computer and use it in GitHub Desktop.
10秒おきにカーソルが動いてスクリーンセーバー起動を阻止
#!/usr/bin/env python3
# iambusy.py 10秒おきにマウスカーソルが少しだけ動いてスクリーンセーバー起動を阻止する
import pyautogui
# pyautogui関数を呼び出すたびに1秒待つ
pyautogui.PAUSE = 10
pyautogui.FAILSAFE = True
print('中断するにはCtrl-Cを押してください')
# カーソルを中央に移動し、10秒おきに左右に100ピクセルくらい動かす
pyautogui.moveTo(860, 540)
try:
while True:
pyautogui.moveRel(100, 0, duration=0.25)
pyautogui.moveRel(-100, 0, duration=0.25)
except KeyboardInterrupt:
print('\n終了')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment