Looking for a script to close a specific program and then put PC to sleep

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
loadinator
Posts: 16
Joined: 12 Apr 2017, 11:41

Looking for a script to close a specific program and then put PC to sleep

27 Apr 2024, 10:50

I have a program that i need closing after a certain amount of time, lets say one hour, then i want the PC to sleep straight after, does anyone know of a script that can do this?
User avatar
mikeyww
Posts: 28869
Joined: 09 Sep 2014, 18:38

Re: Looking for a script to close a specific program and then put PC to sleep

27 Apr 2024, 12:24

Code: Select all

#Requires AutoHotkey v2.0
winTitle       := 'ahk_exe Notepad.exe'
closeAfterMins := 60
SoundBeep 2500
WinWait winTitle
SoundBeep 1500
If !WinWaitClose(,, 60 * closeAfterMins) {
 WinClose
 SoundBeep 1000
 DllCall('PowrProf\SetSuspendState', 'Int', 0, 'Int', 0, 'Int', 0) ; Sleep computer
}
ExitApp

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: boardtc, DavidP and 50 guests