Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A program allowing you to enter hours and minutes until you want computer
- # to shutdown. Useful for leaving a download running etc.
- import pygame
- from pygame.locals import *
- pygame.init()
- minutes = 60
- hours = 3600
- print("\n\tWelcome to the shutdown program!")
- print("\nYou can type ABORT to cancel the shutdown")
- print("\nAt any time, press ESCAPE to abort and close.")
- selection = raw_input("\nWill you want to shutdown in over an hour? (y/n) ")
- if selection == 'y':
- timehours = input("\nHow many hours: ")
- timeminutes = input("\nHow many minutes: ")
- totaltime = ((timehours * hours) + (timeminutes * minutes))
- print("\nShutdown will commence in " + str(timehours) + " hours and " + str(timeminutes) + " minutes")
- if selection == 'n':
- timeminutes = input("\nHow many minutes until shutdown: ")
- totaltime = timeminutes * minutes
- print("\nShutdown will commence in " + str(totaltime) + " minutes.")
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- pygame.quit()
- sys.exit()
- file = open("Shutdown.bat", "w")
- newLine = "c:\windows\system32\shutdown -s -f -t " + str(totaltime)
- file.write(newLine)
- file.close()
- import os
- os.startfile('C:\Documents and Settings\George\My Documents\Python\Python Programs\Shutdown.bat')
- abort = raw_input("Type ABORT to cancel shutdown. Otherwise press ESCAPE to exit.\n")
- abort = str.lower(abort)
- if abort == 'abort':
- import os
- os.startfile('C:\Documents and Settings\George\My Documents\Python\Python Programs\Abort.bat')
- print("Shutdown cancelled")
Add Comment
Please, Sign In to add comment