Home > Archive > Smartphone Developer Forum > January 2005 > Trapping power button...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Trapping power button...
|
|
|
| How can I trap the power button to run my application? Once in my
application, I'd like to map a softkey to the power button function - how do
I call that too?
I don't need code - just a trail to follow. I'll figure it out for myself -
I just need a place to start looking.
Thanks.
-Will
| |
| Charles Schweizer [MSFT] 2005-01-23, 4:03 pm |
| I don't believe it's possible to get notifications of power-button presses.
I assume you've tried RegisterHotKey, but you might also check out
SHCMBM_OVERRIDEKEY
(http://msdn.microsoft.com/library/d..._guide_qgcc.asp).
If you do find a way, you should be able to simulate the power key with
this:
(http://msdn.microsoft.com/library/d...c_2002_hmlm.asp)
keybd_event(VK_OFF,0,KEYEVENTF_SILENT,0)
;
keybd_event(VK_OFF,0,KEYEVENTF_SILENT | KEYEVENTF_KEYUP,0);
sleep(60);
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Charles Schweizer [MSFT]
cschweiz@online.microsoft.com
Remove "online" if you're not an e-mail harvester...
-----------------------------
"WillT" <will@nospam.com> wrote in message
news:TzZAd.15188$He3.11447@trndny05...
> How can I trap the power button to run my application? Once in my
> application, I'd like to map a softkey to the power button function - how
> do I call that too?
>
> I don't need code - just a trail to follow. I'll figure it out for
> myself - I just need a place to start looking.
>
> Thanks.
>
> -Will
>
>
| |
|
| Charles Schweizer [MSFT] wrote:
> keybd_event(VK_OFF,0,KEYEVENTF_SILENT,0)
;
> keybd_event(VK_OFF,0,KEYEVENTF_SILENT | KEYEVENTF_KEYUP,0);
> sleep(60);
Have you tried that? if memory serves it won't get to the second line
responds as if the first line was a press-n-hold.
So shuts down straight away.
PS I havn't used the KEYEVENTF_SILENT, but i suspect it's not needed.
just my 0.02Euro, could be wrong, but last time i was dealing with this
stuff i had some 'fun' getting things working.
oh and PS you'll want to flush out the registry to disk too.
riki
main(){printf("%d != %d, why?\n", sizeof('"')["'"],
(sizeof('"'))["]\"\0["]);}
By Night:
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
By Day: http://www.EmbeddedFusion.com
| |
|
|
|
| It might differ from phone to phone, but on the HTC Typhoon (5600) the power
button actually is App Key 4 (VK_APP4), and it only sends VK_POWER once you
hold it down for 2-3 seconds. You can try and trap the VK_APP4 key press.
The easiest way is to use GAPI's keyboard input mode in my opinion. But you
can also use one of the aygshell SHSetAppWnd or something like that to
specify that your window should receive that key's press.
If you want to run the program once this key is pressed in the future though
it's more complicated. CE 4.2 sdk suggests
HKLM\Software\Microsoft\Shell\Keys\40C# where # is the key number in VK_APP#
messages. Set Application key to filename and Path to the app path. I have
not seen this work on my device, but that's the sdk for you.
Alternately, on my device this button is mapped to launch quickapp.exe.
This is specified in the registry. How it gets set I don't know yet, but it
maps to the following registry key:
HKLM\SOFTWARE\Microsoft\Shell\RAI\:MSQui
ckApp
You can modify key "1" and change it to your app's full commandline
This also works for other mapped keys. So VK_APPV3 (Volume_Up held down) is
linked to :MSTNotes, and Volume_down held down is VK_RECORD (or is it
VK_TRECORD?) which maps to one of these as well. If you modify these keys,
make a backup, cause otherwise you won't be able to run some of these apps
even from the startmenu since those links reference these registry keys.
"WillT" wrote:
>
> There's a screen shot program that works with the power key:
> http://www.smartphone.net/software_detail.asp?id=868
>
> How is that done?
>
> -Will
>
>
>
|
|
|
|
|