Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- #SingleInstance force
- #HotIf BlockKeys == 1
- Space::return
- l::return
- #HotIf
- ^!#BS up::{
- global BlockKeys := 1
- SuspendPC()
- }
- SuspendPC(){
- MyGui := Gui("+AlwaysOnTop", "Suspending PC")
- MyGui.Add("Text", "w300 Center", "Press Spacebar to abort or L to log off immediately.")
- MyGui.Add("Text", "vtimer w300 Center", 5)
- MyGui.Add("Progress", "vprog w300 h20 cBlue", 100)
- MyGui.Show()
- SetTimer(progressbar, 50)
- SetTimer(countdown, 1000)
- progressbar(){
- MyGui["prog"].Value --
- ; suspend pc
- if (MyGui["prog"].Value == 0){
- StopProgress()
- ; DllCall("powrprof\SetSuspendState", "Int",0, "Int",0, "Int",0)
- }
- ; log off
- else if (GetKeystate("l", "P")){
- StopProgress()
- Shutdown(0)
- }
- ; abort
- else if (GetKeystate("space", "P")){
- StopProgress()
- NewGui := Gui("+AlwaysOnTop", "Suspend PC")
- NewGui.Add("Text", "w300 Center", "Suspend / log off aborted.")
- NewGui.Show()
- SetTimer(CloseNewGUI, -2000)
- CloseNewGUI(){
- NewGui.Destroy()
- }
- }
- }
- countdown(){
- if (MyGui["timer"].Value > 0)
- MyGui["timer"].Value --
- ;else
- ; SetTimer(countdown, false)
- }
- StopProgress(){
- global BlockKeys
- SetTimer(countdown, false)
- SetTimer(progressbar, false)
- MyGui.Destroy()
- BlockKeys := 0
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement