Here's what I wound up using in my .AHK file:
DllCall("PowrProf\SetSuspendState", "Int", 0, "Int", 0, "Int", 0)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
want a api or dll to put my w11 PC to SLEEP, nor hibernate or power off
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
Here's what I wound up using in my .AHK file:
DllCall("PowrProf\SetSuspendState", "Int", 0, "Int", 0, "Int", 0)
Welcome Scott Sheridan,
Thank you for reaching out to Microsoft Q&A forum.
Windows provides APIs and DLL functions that can place a Windows 11 PC into Sleep, Hibernate, or Shut Down mode.
For a batch file, one of the simplest methods is: rundll32.exe powrprof.dll,SetSuspendState 0,1,0
You can check this link for the information that powrprof.dll,SetSuspendState can be used to put Windows into a sleep state. How to sleep - Microsoft Q&A
However, on some Windows 11 systems, especially newer devices using Modern Standby (S0), this command may enter Hibernate instead of Sleep if hibernation is enabled. This behavior has been reported by Windows 11 users. Windows 11 24H2 goes into hibernation mode instead of sleep mode. How can I create a sleep mode sho…
To determine which sleep states your PC supports, open Command Prompt (Admin) and run: powercfg /a
This will show whether the device supports:
If the answer is helpful, please click "Yes". If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.