Standby/Suspend/Sleep the PC with AHK takes too long

Get help with using AutoHotkey and its commands and hotkeys
User avatar
WAZAAAAA
Posts: 75
Joined: 13 Jan 2015, 19:48

Standby/Suspend/Sleep the PC with AHK takes too long

21 Feb 2019, 21:57

AutoHotkey is consistently slower than many other programs at entering Standby mode (state S3) for me by a few seconds.
Tested on one machine with Win7+Win10 (dual boot) with hiberfil.sys and pagefile.sys OFF and a second Win7 machine with those ON. Admin or not made no difference.
This has been discussed already in the archived forum, but no solution was found. I can't wrap my head around this so I'm looking for help here.

These are the programs and methods I've tested divided by which was faster and which was slower.

FAST:
Spoiler
SLOW:
  • AutoHotkey calling DllCall("PowrProf\SetSuspendState", "int", 0, "int", 1, "int", 1) (from the Shutdown documentation)
  • AutoHotkey calling DllCall("Kernel32\SetSystemPowerState", "int", 1, "int", 1) (SeShutdownPrivilege required)
  • rundll32.exe Powrprof.dll,SetSuspendState (not recommended, Standby only works if Hibernation is disabled)
  • howto_shutdown_windows.exe
Third party programs have some issues like antivirus false-positives, admin privileges, the PsTools have that annoying 1st time boot EULA windows, the PowerShell method is slow as PS alone takes a long time to load, I don't want to click the Start button it's slow I wanna use a hotkey etc. etc... I just want to do it fast with AHK as I put my PC on standby a lot.

Useful resources:
http://blog.clockahead.com/2012/10/windows.html
https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-setsuspendstate
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.application.setsuspendstate?view=netframework-4.7.2
https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-setsystempowerstate
powercfg -a to check your available power states
powercfg -h off to disable hibernation (S4)



TL;DR putting the PC on standby using AHK is slow for some unknown reason, how do I make it fast like other programs?
YOU'RE NOT ALEXANDER
User avatar
WAZAAAAA
Posts: 75
Joined: 13 Jan 2015, 19:48

Re: Standby/Suspend/Sleep the PC with AHK takes too long

21 Feb 2019, 22:05

I might be an idiot, maybe this belongs to Bug Reports
YOU'RE NOT ALEXANDER
User avatar
nnnik
Posts: 4320
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Standby/Suspend/Sleep the PC with AHK takes too long

27 Feb 2019, 12:51

To be honest I think it should stay in ask for help for now - we will move this to bug reports if somebody has found something relating it to an autohotkey bug.
Recommends AHK Studio

Return to “Ask For Help”

Who is online

Users browsing this forum: agrout, AHKStudent, holahapi, MannyKSoSo and 209 guests