Created
June 18, 2021 14:22
-
-
Save kotoripiyopiyo/0b16460e3b30a2137c35615a1c26a72e to your computer and use it in GitHub Desktop.
10秒おきにカーソルが動いてスクリーンセーバー起動を阻止
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 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