ScreenOff ?

Angelo

Member
Licensed User
Hi,
I'm attempting to write a very simple Sleep Timer App that will suspend the device after a selected amount of time. It is not necessary or desired to leave the screen on during the countdown process. Since the Hardware Library does not support "ScreenOff", I've been scratching my head and searching the forum for hours trying to figure out how get my app to do this. I was hoping to perhaps find a hard keycode for this function but no luck with that. Any advice would be appreciated. Thanks.

Regards,
Angelo
 

Angelo

Member
Licensed User
Jotha,
Thanks for your input but I'm not sure that the thread you refer to helps. It seems in that thread the trouble is keeping the screen on for which there are methods in the hardware library that just were not working for this guy. My problem is that I cannot figure out a way to turn the screen off while keeping the device on playing mp3's while I fall asleep.

Regards,
Angelo
 

Zenerdiode

Active Member
Licensed User
You can turn off the device with Hardware.KeyPress(223). 223 is the value of the power button; and Hardware is an object from Erel's Hardware dll. To answer your problem, you will need to read the value of the 'screen-off' time, program the lowest value you can (if you can go as low as a second - that will be great) and remember to place the original value back in there when you close your app. However you'll have to ask the experts here how to get and set the screen-off value as I don't have a clue if its a registry entry or a memory register to be 'peeked and poked'.

Also be aware that if you use Windows Media player for your mp3s; WMP excercises the keep-alive function so you'll have to shut down your device by other methods than timeout.
 

Angelo

Member
Licensed User
How to program the Screen-Off Time to it's lowest value?

Thanks to all for your suggestions. Although I am not a Newbie to Basic, I would still consider myself a beginner level "Programmer". (Just a hobbiest) When I began writing this simple little app I never thought I would have learned so much from it. You guys are great!

I should have been more clear in my original post. To clarify, I am already utlizing a keypress(223) to suspend the device and it works great. What I am having trouble with is turning off the screen, not the device.

you will need to read the value of the 'screen-off' time, program the lowest value you can (if you can go as low as a second - that will be great) and remember to place the original value back in there when you close your app.QUOTE]


This sounds like the approach I would like to take to turn off the screen while leaving the device on. Although like you, I don't have a clue how to do it. Hopefully the pros might have some suggestions. I will continue to work at it and if I find a solution, I will post it along with the code and sample project here.

Thanks again to everyone!

Regards,
Angelo
 

Angelo

Member
Licensed User
Need Some Expert Help

Hello. After scanning variouse forums for some time, I have learned a bit more. The way to turn the screen off while leaving the device on is to set the registry value to 0 in Registry CurrentUser\ControlPanel\Backlight\Brightness. I have managed to do this with no trouble using the Registry Library.

PHP:
Sub App_Start
      reg.New1 'reg is Registry Object
      reg.RootKey(reg.rtCurrentUser)
      reg.SetDWordValue("ControlPanel\BackLight","Brightness", 4)  ' Using 4 instead of 0 for testing.  
End Sub


The registry value changes with this code BUT this change will not be recognized by the device until a "BackLightChangeEvent" is fired from the control panel (this is where I am having trouble) at which time the new registry setting are applied. I have tried toggling Backlight On and Backlight Normal with the Hardware Library but apparently this does not trigger the event.

I found this C# code on a forum.

PHP:
'If Changed some item setting within BackLight registry, you can trigger 
'BackLightChangeEvent to let system accept new setting immediately.  
  
HANDLE hEvent = CreateEvent(NULL, FALSE, TRUE, L"BackLightChangeEvent");  
  
if (hEvent) {  
  
SetEvent(hEvent);  
  
CloseHandle(hEvent);  
  
}

I spent a couple of hours trying to transpose it to the Door library but it's quite obviouse that I'm in over my head and I'm not sure if this is even possible.

Anyone with some experience with the .Net Framework care to chime in? Is this possible? Be advised that the registry setting locations and even the Event name may be OEM specific. But I believe the defaults are as described above and should be this way for many devices. Thanks Again!:)
 

agraham

Expert
Licensed User
Longtime User
I found this C# code on a forum.
I'm afraid those are Windows kernel calls in native C/C++ code not C#. Those functions are not available in .NET. They could be called from a specially written library using P/Invoke but you can't get at them with the Door library.
 

Angelo

Member
Licensed User
Not Possible

Agraham,

I will not be writing my own libraries anytime soon (I do not have the required knowledge or software) but if / when I do, this seems like a good first project. At least now I know that I can stop attempting to use the Door Library for this. Thanks so much for your advice.

Regards,
Angelo
 

chr

New Member
Somebody implemented somehow the screen off function.
See: ht*p://www.flytrap.it/default.asp?p=blackme.

P.S. You have to change the star with t, as I don't have yet the ability to post url.
 
Top