Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-19-2008, 01:09 AM
Senior Member
 
Join Date: Nov 2007
Posts: 128
Default Detecting if the monitor is on or off?

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.
Reply With Quote
  #2 (permalink)  
Old 12-19-2008, 08:42 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

This feature is only available in vista or windows server 2008.
Reply With Quote
  #3 (permalink)  
Old 12-19-2008, 11:15 PM
Senior Member
 
Join Date: Nov 2007
Posts: 128
Default

What about WM_SYSCOMMAND SC_MONITORPOWER?
Reply With Quote
  #4 (permalink)  
Old 12-29-2008, 08:10 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

I'm sorry this problem is difficult, as well as the "detecting standing by" one.
Reply With Quote
  #5 (permalink)  
Old 12-29-2008, 08:10 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

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");
Reply With Quote
  #6 (permalink)  
Old 12-29-2008, 11:15 AM
Senior Member
 
Join Date: Nov 2007
Posts: 128
Default

Is there a way to constantly trace the value of this? Or detect when it's value changes?
Reply With Quote
  #7 (permalink)  
Old 12-29-2008, 01:08 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

Quote:
Originally Posted by motionman95 View Post
Is there a way to constantly trace the value of this? Or detect when it's value changes?
You can write a detecting function, and run it at some regular intervals, say every second, by calling the setInterval method.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:31 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.