Guest User

Untitled

a guest
May 26th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. # A program allowing you to enter hours and minutes until you want computer
  2. # to shutdown. Useful for leaving a download running etc.
  3.  
  4. import pygame
  5. from pygame.locals import *
  6. pygame.init()
  7.  
  8. minutes = 60
  9. hours = 3600
  10.  
  11. print("\n\tWelcome to the shutdown program!")
  12. print("\nYou can type ABORT to cancel the shutdown")
  13. print("\nAt any time, press ESCAPE to abort and close.")
  14. selection = raw_input("\nWill you want to shutdown in over an hour? (y/n) ")
  15.  
  16. if selection == 'y':
  17. timehours = input("\nHow many hours: ")
  18. timeminutes = input("\nHow many minutes: ")
  19. totaltime = ((timehours * hours) + (timeminutes * minutes))
  20. print("\nShutdown will commence in " + str(timehours) + " hours and " + str(timeminutes) + " minutes")
  21.  
  22. if selection == 'n':
  23. timeminutes = input("\nHow many minutes until shutdown: ")
  24. totaltime = timeminutes * minutes
  25. print("\nShutdown will commence in " + str(totaltime) + " minutes.")
  26.  
  27. for event in pygame.event.get():
  28. if event.type == QUIT:
  29. pygame.quit()
  30. sys.exit()
  31. if event.type == KEYDOWN:
  32. if event.key == K_ESCAPE:
  33. pygame.quit()
  34. sys.exit()
  35.  
  36. file = open("Shutdown.bat", "w")
  37. newLine = "c:\windows\system32\shutdown -s -f -t " + str(totaltime)
  38. file.write(newLine)
  39. file.close()
  40.  
  41. import os
  42. os.startfile('C:\Documents and Settings\George\My Documents\Python\Python Programs\Shutdown.bat')
  43.  
  44. abort = raw_input("Type ABORT to cancel shutdown. Otherwise press ESCAPE to exit.\n")
  45. abort = str.lower(abort)
  46.  
  47. if abort == 'abort':
  48. import os
  49. os.startfile('C:\Documents and Settings\George\My Documents\Python\Python Programs\Abort.bat')
  50. print("Shutdown cancelled")
Add Comment
Please, Sign In to add comment