|
|||
|
Using swfkit, can I listen to GUID_MONITOR_POWER_ON and detect when the monitor is on or off? I'm in XP.
GUID_MONITOR_POWER_ON - 02731015-4510-4526-99e6-e5a17ebd1aea The monitor on/off notification indicates when the primary system monitor is on or off. This notification is useful for components that actively render content to the display device, such as media visualization. These applications should register for this notification and stop rendering graphics content when the monitor is off to reduce system power consumption. The Data member is a DWORD that indicates the current monitor state. 0x0 The monitor is off. 0x1 The monitor is on. |
|
|||
|
Fortunately for this problem the following code seems to work well.
Code:
dllimport "kernel32.dll" stdcall long GetDevicePowerState(long, long*);
dllimport "kernel32.dll" stdcall long CreateFileA(String, long, long, long, long, long, long) as CreateFile;
var GENERIC_READ = 0x80000000;
var GENERIC_WRITE = 0x40000000;
var OPEN_EXISTING = 3;
dl = CreateFile("\\\\.\\LCD", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
trace(dl);
var state = new Object;
state.value = false;
result = GetDevicePowerState(dl, state);
if (!result) trace("the method has failed!");
else trace("The state of the monitor is ", state.value ? "on" : "off");
|
|
|||
|
You can write a detecting function, and run it at some regular intervals, say every second, by calling the setInterval method.
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|