Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to enter to hybrid sleep


  • Please log in to reply
6 replies to this topic
Revil
  • Members
  • 23 posts
  • Last active: Jun 04 2013 12:55 PM
  • Joined: 12 Jan 2012
Hello,
I found the Shutdown command but I also found that Shutdown command cannot be used for sleep and hibernation modes. In examples I found DllCall for these modes. If I understand correctly then:

DllCall(“PowrProf\SetSuspendState”, “int”, 0, “int”, 0, “int”, 0) ; Sleep
and
DllCall(“PowrProf\SetSuspendState”, “int”, 1, “int”, 0, “int”, 0) ; Hibernation

But please can somebody tell me, how to enter to “Hybrid sleep”? Hybrid sleep is sleep mode that is secured by storing data from memory on the hard drive (like hibernation).

Thank you.

trismarck
  • Members
  • 385 posts
  • Last active: Yesterday, 11:10 PM
  • Joined: 02 Dec 2010
I don't know if that helps, but anyway: <!-- m -->http://social.techne... ... 99b92e91ac<!-- m -->

I also have a .bat script that will put the computer in the Standby mode:
@echo off
echo Do you really want to Standby? 
echo Press Ctrl+C to abort.
pause 1>nul
rem turn off the hibernation mode
powercfg -h off
%windir%\system32\rundll32.exe PowrProf SetSuspendState
rem turn on the hibernation mode
powercfg -h on
Maybe there is a switch for powercfg command on Windows 7 for hybrid sleep. Or maybe there is a registry setting for hybrid sleep.

bogser
  • Members
  • 9 posts
  • Last active: Apr 05 2012 07:37 AM
  • Joined: 09 Jan 2011
There is mistake in your code. The proper variant:
DllCall("PowrProf\SetSuspendState", "Char", 0, "Char", 0, "Char", 0) ; Sleep
If hybrid sleep is enabled in your settings (http://maximumpcguid...on-in-windows-7) above-mentioned command should enter your computer into hybrid sleep.

Revil
  • Members
  • 23 posts
  • Last active: Jun 04 2013 12:55 PM
  • Joined: 12 Jan 2012

Maybe there is a switch for powercfg command on Windows 7 for hybrid sleep.

Hello,
I just check powercfg and there is not any switch that force hybrid sleep. Thank you for your bat file but I think that making bat file is not necessary because the same functionality can be achieved using AutoHotkey. It is not possible to use Shutdown command for sleep and hibernation but there is not a problem to use DllCall.


There is mistake in your code.

Thank you but are you sure? Check this: <!-- m -->http://www.autohotke...ds/Shutdown.htm<!-- m -->

; Call the Windows API function "SetSuspendState" to have the system suspend or hibernate.
; Windows 95/NT4: Since this function does not exist, the following call would have no effect.
; Parameter #1: Pass 1 instead of 0 to hibernate rather than suspend.
; Parameter #2: Pass 1 instead of 0 to suspend immediately rather than asking each application for permission.
; Parameter #3: Pass 1 instead of 0 to disable all wake events.
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)



If hybrid sleep is enabled in your settings (http://maximumpcguid...on-in-windows-7) above-mentioned command should enter your computer into hybrid sleep.

I wanted to create function that will be independent on the settings so the function should choose hibernation or hybrid sleep independently on current Windows settings. But thanks to trismarck I have an idea. The function could perform some RegWrite before DllCall and change the registry entries that define whether hibernation / hybrid sleep will be used. But I have to found those registry entries.

bogser
  • Members
  • 9 posts
  • Last active: Apr 05 2012 07:37 AM
  • Joined: 09 Jan 2011

Thank you but are you sure?

Yes. From SetSuspendState documentation:
BOOLEAN WINAPI SetSuspendState(
  __in  BOOLEAN Hibernate,
  __in  BOOLEAN ForceCritical,
  __in  BOOLEAN DisableWakeEvent
);
BOOLEAN is BYTE, BYTE is unsigned char.

The function could perform some RegWrite before DllCall and change the registry entries that define whether hibernation / hybrid sleep will be used. But I have to found those registry entries.

I think you should use some of the power management functions for changing sleep settings. But it seems it's not trivial.

bogser
  • Members
  • 9 posts
  • Last active: Apr 05 2012 07:37 AM
  • Joined: 09 Jan 2011
As recently found out DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) variant is also valid. See here and here for details.

CodeKiller
  • Members
  • 2067 posts
  • Last active: Sep 02 2014 09:17 AM
  • Joined: 10 Jul 2008
int 0 is the same thing as char 0 for a function call like this one.

By the way in size : BOOLEAN = BYTE|CHAR (1 byte) < INT (2 bytes)
But all int > 0 (or < 0) are True (in fact if int <> 0 then true).