0

Im trying to make an idle program which shuts down my computer after a length of time. At the moment, I am testing tkinter yes or no prompt to make sure if the user is still awake. I want it to be if the user hasn't answered in 30 seconds, then it moves the mouse over to No and clicks on it. But it seems I can't put both tkinter prompt and pyautogui together.

import tkinter as tk
from tkinter import messagebox
import time
import pyautogui

while True:
    result = messagebox.askyesno(
        title='Yes No Demo',
        message='Are you awake?',
        detail='Click No to stay active'
    )
    pyautogui.moveTo(1026, 620, duration = 0)
    time.sleep(3)
    pyautogui.click()
    if result == "True":
        time.sleep(3)
    else:
        break
HuskWolfy
  • 9
  • 1

1 Answers1

-1

Well, your question title and code don't make sense together. If you wonder how you can shut your PC down, import sys lib and learn about the CMD shutdown commands.

Mani
  • 45
  • 12