ScreenOff ?

Discussion in 'Questions (Windows Mobile)' started by Angelo, Sep 14, 2008.

  1. Angelo

    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
     
  2. JOTHA

    JOTHA Well-Known Member Licensed User

  3. 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
     
  4. BjornF

    BjornF Active Member Licensed User

    Dear Angelo, a possible "messy" and indirect solution would be to use MortSaver (a freeware program: www.sto-helit.de - MortSaver 2.0 (simple PDA without phone)).

    I haven't tested starting it with the shell command, but if that doesn't work then I am fairly certain that you can do it via Mortscript from the same site.

    all the best / Björn
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It is possible to turn off the device by sending a special key.
    I currently don't remember its value but I can find it if it will help you.
    Turning off the device will also stop all programs.
     
  6. Zenerdiode

    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.
     
  7. Angelo

    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.

     
  8. 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(NULLFALSETRUEL"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!:)
     
  9. agraham

    agraham Expert Licensed User

    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.
     
  10. Angelo

    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
     
  11. chr

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice