※실행시 일정시간마다 마우스와 키보드 입력을 주는 것을 통해 화면꺼짐을 방지하는 방식입니다!!
import pyautogui
import time
import random
우선 필요한 라이브러리들을 불러와 줍니다.
while True:
pyautogui.FAILSAFE = True
screenW, screenH = pyautogui.size()
temp_x, temp_y = pyautogui.position()
time.sleep(10)
current_x, current_y = pyautogui.position()
if temp_x == current_x and temp_y == current_y:
ran_w = random.randint(1, screenW)
ran_h = random.randint(1, screenH)
pyautogui.moveTo(ran_w, ran_h, 0.3)
pyautogui.typewrite(" ", 1)
인터럽트가 발생하거나 중단하기 전까지 계속 실행되는 방식으로
10초마다 마우스 커서의 위치를 바꾸고 키보드에 " " 입력을 주는것을 통해 화면 꺼짐을 방지합니다!!
'잡동사니' 카테고리의 다른 글
| 파이썬을 이용한 CGV 용산 아이파크몰 IMAX 예매 알리미 (0) | 2024.08.20 |
|---|