Advertisement
TheNoobPolice

Untitled

Dec 28th, 2022
1,532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance force
  3.  
  4. #HotIf BlockKeys == 1
  5.     Space::return
  6.     l::return
  7. #HotIf 
  8.  
  9. ^!#BS up::{
  10.     global BlockKeys := 1
  11.     SuspendPC()
  12.     }
  13.  
  14. SuspendPC(){
  15.     MyGui := Gui("+AlwaysOnTop", "Suspending PC")
  16.     MyGui.Add("Text", "w300 Center", "Press Spacebar to abort or L to log off immediately.")
  17.     MyGui.Add("Text", "vtimer w300 Center", 5)
  18.     MyGui.Add("Progress", "vprog w300 h20 cBlue", 100)
  19.     MyGui.Show()
  20.     SetTimer(progressbar, 50)
  21.     SetTimer(countdown, 1000)
  22.    
  23.     progressbar(){
  24.         MyGui["prog"].Value --
  25.        
  26.         ; suspend pc
  27.         if (MyGui["prog"].Value == 0){
  28.             StopProgress()
  29.             ; DllCall("powrprof\SetSuspendState", "Int",0, "Int",0, "Int",0)
  30.             }
  31.            
  32.         ; log off
  33.         else if (GetKeystate("l", "P")){
  34.             StopProgress()
  35.             Shutdown(0)
  36.             }
  37.    
  38.         ; abort
  39.         else if (GetKeystate("space", "P")){
  40.             StopProgress()
  41.             NewGui := Gui("+AlwaysOnTop", "Suspend PC")
  42.             NewGui.Add("Text", "w300 Center", "Suspend / log off aborted.")
  43.             NewGui.Show()
  44.             SetTimer(CloseNewGUI, -2000)
  45.                 CloseNewGUI(){
  46.                     NewGui.Destroy()
  47.                 }
  48.             }
  49.     }
  50.  
  51.     countdown(){
  52.         if (MyGui["timer"].Value > 0)
  53.             MyGui["timer"].Value --
  54.         ;else
  55.         ;   SetTimer(countdown, false)
  56.     }
  57.    
  58.     StopProgress(){
  59.         global BlockKeys
  60.  
  61.         SetTimer(countdown, false)
  62.         SetTimer(progressbar, false)
  63.         MyGui.Destroy()
  64.         BlockKeys := 0
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement