[python-win32] python-win32 Digest, Vol 112, Issue 3

prashant padaganur prashantpadaganur at gmail.com
Wed Jul 4 12:20:57 CEST 2012


>
> Date: Wed, 04 Jul 2012 08:24:22 +0100
> From: Tim Golden <mail at timgolden.me.uk>
>  On 04/07/2012 06:01, prashant padaganur wrote:
> > On 03/07/2012 12:23, prashant padaganur wrote:
> >>>/
> > />>/ I want to write an application that puts the system in to different
> > />>/ sleep states. Like S0,S1...S4.
> > />>/
> > />>/ Before changing from one state to another I want to know the
> > />>/ current/previous sleep state.
> > />>/
> > />>/ For Ex: If the current state is S0 then I want to put it to S1. Or
> if
> > />>/ the previous state was S3 then I want to put the system to S4.
> > />>/
> > />>/ I want to know how can I get this state info from python using Win32
> > />>/ apis. The related struct I found on MSDN is SYSTEM_POWER_STATE
> > />>/
> > />>/
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx
> > />
> >>Chances are that WMI can do it: try Googling for "WMI power management"
> >>or something similar
> >>
> >>TJG
> >
> > No luck so far. If anyone has done something similar please share your
> thoughts.
>
>
> Well I haven't, but I Googled for "WMi power management", found this as
> the 3rd hit:
>
>   http://www.vbsedit.com/scripts/desktop/info/scr_233.asp
>
>
> which led me to look at this page in MSDN:
>
>
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa394102%28v=vs.85%29.aspx
>
>
> and the PowerState attribute:
>
>
> """
> PowerState
>
>     Data type: uint16
>     Access type: Read-only
>
>     Current power state of a computer and its associated operating
> system. The power saving states have the following values: Value 4
> (Unknown) indicates that the system is known to be in a power save mode,
> but its exact status in this mode is unknown; 2 (Low Power Mode)
> indicates that the system is in a power save state, but still
> functioning and may exhibit degraded performance; 3 (Standby) indicates
> that the system is not functioning, but could be brought to full power
> quickly; and 7 (Warning) indicates that the computer system is in a
> warning state and a power save mode. This property is inherited from
> CIM_UnitaryComputerSystem.
>
>     Value       Meaning
>
>     0 (0x0)
>     Unknown
>
>     1 (0x1)
>     Full Power
>
>     2 (0x2)
>     Power Save - Low Power Mode
>
>     3 (0x3)
>     Power Save - Standby
>
>     4 (0x4)
>     Power Save - Unknown
>
>     5 (0x5)
>     Power Cycle
>
>     6 (0x6)
>     Power Off
>
>     7 (0x7)
>     Power Save - Warning
> """
>
> which looks to me very similar to the SYSTEM_POWER_STATE struct you
> referenced from MSDN. Can you say whether this is what you're looking for?
>
> <code>
> import wmi
>
> c = wmi.WMI()
> for sys in c.Win32_ComputerSystem():
>   print sys.PowerState
>
> </code>
>
>  TJG
> ------------------------------
>

Tim this might be something similar, but what I am looking for is sleep
state. I want the exact api which exposes/returns the  SYSTEM_POWER_STATE
enum either thru win32ap or wmi.

Thank for the help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120704/a5f94f41/attachment.html>


More information about the python-win32 mailing list