Platforms to show: All Mac Windows Linux Cross-Platform

WindowsPowerStateMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Power MBS Win Plugin 6.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
A class to watch for power changes on a computer using Microsoft Windows as operation system.

Not all Windows versions call the same/all events.
Your application needs to run the event loop, so events get delivered.

This function listens for WM_POWERBROADCAST sent to all applications.


You need to run ListenForSuspendResumeNotification to receive suspend/resume events.

Lid States

Constant Value Description
LidClosed 0 The lid is closed.
LidOpened 1 The lid is opened.

Power Source States

Constant Value Description
PowerSourceAC 0 The computer is powered by an AC power source (or similar, such as a laptop powered by a 12V automotive adapter).
PowerSourceDC 1 The computer is powered by an onboard battery power source.
PowerSourceUPS 2 The computer is powered by a short-term power source such as a UPS device.

This class has no sub classes.

Some examples using this class:

Blog Entries

Release notes

  • Version 23.4
    • Added BatteryCapacityChanged, LidSwitchStateChanged and PowerSourceChanged events to WindowsPowerStateMBS class.
    • Added ListenForBatteryCapacityChanged, ListenForLidSwitchStateChanged, ListenForPowerSourceChanged and ListenForSuspendResumeNotification methods to WindowsPowerStateMBS class.
    • Added PowerSettingChange event for WindowsPowerStateMBS class.

The items on this page are in the following plugins: MBS Win Plugin.

WindowsPlayerMBS   -   WindowsPreviewHandlerMBS

The biggest plugin in space...