Hello,
I have a process that runs in the background that I want to use to detect a
press and hold of the power button. The process has no window. It just has a
running message loop. Therefore, I cannot use RegisterHotkey. Is there
another way that I could detect when the power key is pressed and/or held?

Thanks

Re: Detect key press without window, find process by ctacke/>

ctacke/>
Sun Oct 22 16:13:36 CDT 2006

For what reason? There's no way for an application to stop a device from
powering down, and it's highly unlikely that an app will be able to run any
code before shutdown occurs. Knowing if it occurred usually happens after
the device wakes back up, and this is done by hooking into the power
notification queue.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Jonathan King" <JonathanKing@discussions.microsoft.com> wrote in message
news:E728ACBD-4170-4D65-B9A1-F90A99054DD6@microsoft.com...
> Hello,
> I have a process that runs in the background that I want to use to detect
> a
> press and hold of the power button. The process has no window. It just has
> a
> running message loop. Therefore, I cannot use RegisterHotkey. Is there
> another way that I could detect when the power key is pressed and/or held?
>
> Thanks



Re: Detect key press without window, find process by JonathanKing

JonathanKing
Sun Oct 22 16:40:02 CDT 2006

I do not wish to prevent the device from powering down and I do not
necessarily need code to run before the shutdown. I mainly want to react to
the user pressing and holding the power button, which only dims the
backlight. Does anyone know how this can be accomplished? Thanks for any
suggestions.

"<ctacke/>" wrote:

> For what reason? There's no way for an application to stop a device from
> powering down, and it's highly unlikely that an app will be able to run any
> code before shutdown occurs. Knowing if it occurred usually happens after
> the device wakes back up, and this is done by hooking into the power
> notification queue.
>
>
> --
> Chris Tacke
> OpenNETCF Consulting
> Managed Code in the Embedded World
> www.opennetcf.com
> --
>
>
> "Jonathan King" <JonathanKing@discussions.microsoft.com> wrote in message
> news:E728ACBD-4170-4D65-B9A1-F90A99054DD6@microsoft.com...
> > Hello,
> > I have a process that runs in the background that I want to use to detect
> > a
> > press and hold of the power button. The process has no window. It just has
> > a
> > running message loop. Therefore, I cannot use RegisterHotkey. Is there
> > another way that I could detect when the power key is pressed and/or held?
> >
> > Thanks
>
>
>

Re: Detect key press without window, find process by ctacke/>

ctacke/>
Sun Oct 22 22:10:59 CDT 2006

Is that common behavior (the device on my desktop now doesn't do that, it
powers down)? It's likey something only the OEM will be able to tell you
(and who knows if they will).


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Jonathan King" <JonathanKing@discussions.microsoft.com> wrote in message
news:F366458F-60A6-48EA-9B53-A06E37C5225A@microsoft.com...
>I do not wish to prevent the device from powering down and I do not
> necessarily need code to run before the shutdown. I mainly want to react
> to
> the user pressing and holding the power button, which only dims the
> backlight. Does anyone know how this can be accomplished? Thanks for any
> suggestions.
>
> "<ctacke/>" wrote:
>
>> For what reason? There's no way for an application to stop a device from
>> powering down, and it's highly unlikely that an app will be able to run
>> any
>> code before shutdown occurs. Knowing if it occurred usually happens
>> after
>> the device wakes back up, and this is done by hooking into the power
>> notification queue.
>>
>>
>> --
>> Chris Tacke
>> OpenNETCF Consulting
>> Managed Code in the Embedded World
>> www.opennetcf.com
>> --
>>
>>
>> "Jonathan King" <JonathanKing@discussions.microsoft.com> wrote in message
>> news:E728ACBD-4170-4D65-B9A1-F90A99054DD6@microsoft.com...
>> > Hello,
>> > I have a process that runs in the background that I want to use to
>> > detect
>> > a
>> > press and hold of the power button. The process has no window. It just
>> > has
>> > a
>> > running message loop. Therefore, I cannot use RegisterHotkey. Is there
>> > another way that I could detect when the power key is pressed and/or
>> > held?
>> >
>> > Thanks
>>
>>
>>



Re: Detect key press without window, find process by JonathanKing

JonathanKing
Sun Oct 22 23:17:01 CDT 2006

Yes, I'm pretty sure its common behavior. Does anyone have any ideas how this
might be accomplished? Does the GetAsyncKeyState function not work with
VK_OFF?

"<ctacke/>" wrote:

> Is that common behavior (the device on my desktop now doesn't do that, it
> powers down)? It's likey something only the OEM will be able to tell you
> (and who knows if they will).
>
>
> --
> Chris Tacke
> OpenNETCF Consulting
> Managed Code in the Embedded World
> www.opennetcf.com
> --
>
>
> "Jonathan King" <JonathanKing@discussions.microsoft.com> wrote in message
> news:F366458F-60A6-48EA-9B53-A06E37C5225A@microsoft.com...
> >I do not wish to prevent the device from powering down and I do not
> > necessarily need code to run before the shutdown. I mainly want to react
> > to
> > the user pressing and holding the power button, which only dims the
> > backlight. Does anyone know how this can be accomplished? Thanks for any
> > suggestions.
> >
> > "<ctacke/>" wrote:
> >
> >> For what reason? There's no way for an application to stop a device from
> >> powering down, and it's highly unlikely that an app will be able to run
> >> any
> >> code before shutdown occurs. Knowing if it occurred usually happens
> >> after
> >> the device wakes back up, and this is done by hooking into the power
> >> notification queue.
> >>
> >>
> >> --
> >> Chris Tacke
> >> OpenNETCF Consulting
> >> Managed Code in the Embedded World
> >> www.opennetcf.com
> >> --
> >>
> >>
> >> "Jonathan King" <JonathanKing@discussions.microsoft.com> wrote in message
> >> news:E728ACBD-4170-4D65-B9A1-F90A99054DD6@microsoft.com...
> >> > Hello,
> >> > I have a process that runs in the background that I want to use to
> >> > detect
> >> > a
> >> > press and hold of the power button. The process has no window. It just
> >> > has
> >> > a
> >> > running message loop. Therefore, I cannot use RegisterHotkey. Is there
> >> > another way that I could detect when the power key is pressed and/or
> >> > held?
> >> >
> >> > Thanks
> >>
> >>
> >>
>
>
>

Re: Detect key press without window, find process by JonathanKing

JonathanKing
Wed Oct 25 12:43:02 CDT 2006

It seems like GetAsyncKeyState does not work with VK_OFF or VK_TPOWER. Are
there any other aliases for the power key? Any other ideas of how to
accomplish this? I don't want to prevent a power off. I just want to know if
the button is held. Please help. Thanks.