Solved

"Home" button on HTC Windows Mobile 6.5 phones

Posted on 2010-09-10
21
948 Views
Last Modified: 2013-12-27
I've got an interesting problem with THC HD Mini with WinMo 6.5 (and I guess it is true for at least few other HTC phones with WM 6.5)

As you can see at the image, Mini has 4 buttons at the bottom: Talk, Home, Menu and End.
"Menu" button is actually good old VK_THOME and shows what was accessible before from clicking "Start" in previous WinMo versions. But "Home" button is more elusive - it shows Today screen.

My goal is to detect (1) what code it generates, or (2) how to simulate it, or (3) how can I achieve the same as "Home" button click, ie force Today screen to be shown - from the application.

Any ideas are very welcome.
0
Comment
Question by:alexey_gusev
  • 9
  • 9
21 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 33661195
Here are the current keys for 6.5.

http://msdn.microsoft.com/en-us/library/bb431750.aspx

It seems that  VK_THOME  is still the option for the Home button.
0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33661262
Hi Mikal,

I'm afraid I should disappoint you :) - VK_THOME is great, but it is generated by a button with "windows logo" on it, and what's more, I do catch it as a hot key with VK_THOME, and even more :), it is defined in SDK as VK_LWIN. This question is purely HTC related.

I've discovered that this Home button generates the code 0xED which is marked as from OEM pool. I was even able to set keyboard hook and catch it within the application, but NOT simulate the click.

So I do appreciate your help, but it's not as easy as simple Google query :)
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33666672
I do not know the answer.

keyb_event and, maybe, SendInput will simulate these hardware buttons very well.
You maybe know, OEM can use own keyboard events - I do not remember all details, it was 2 years ago, I attached the code I have - 0xE9 means something there.

I think in a small windows app you can catch these buttons - it should be WM_SYSKEYDOWN/WM_SYSKEYUP messages.
I'd use this way. :) I'm sure, you will excuse me if I'm wrong.

void EmulateKeyboard()
{
   EnableHardwareKeyboard(FALSE);
   keybd_event(0xE9, 0, KEYEVENTF_SILENT, 0);
   keybd_event(0xE9, 0, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0);
}

Open in new window

0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33666840
@pgnatyuk: ha ha, surely I'll excuse you - I do appreciate your help :)

I'll check EnableHardwareKeyboard() tomorrow. It should be something about the right combination of 'tricks' to get it working :)

Funny thing, if I use keybd_event() with 0xED it generates WM_KEYDOWN/UP with the code 0xE5 (VK_PROCESSING), but doesn't navigate to Today screen.

In the hook function, the virtual code is 0xED, scancode = 0, flags = 0. So I've tried various combinations already, even searched the registry for application keys (there were those in previous versions) - but nada, it doesn't do what I want.

Alternatively, what is the window that contains all menu items on wm6.5 called? It does contain Today icon, but again, I've found all shortcuts but this one under \Windows :)
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33667184
:( I do not know. I do not work with the Windows Mobile phones now.

You don't want to try WM_SYSKEYDOWN? I think in a fullscreen application, when you will press on these hardware buttons, in the window procedure you can catch them. I think so. It did work for Windows Mobile 5 and 6. I do not remember any change about it in 6.5, so it should work.
Have you checked all kind f GetAsyncKeyState, MapVirtualKey, GetKeyState?

I re-read your question:
>>(3) how can I achieve the same as "Home" button click, ie force Today screen to be shown - from the application

Something like that:
HWND hWnd = FindWindow(_T("DesktopExplorerWindow"), _T("Desktop"));
or
HWND hWnd = FindWindow(_T("DesktopExplorerWindow"), NULL);
and then
SetForegroundWindow(hWnd)
will work?

And this is from Google (please take a look):
http://www.ceveni.com/2008/11/programmatically-press-keys-in-windows.html

MSDN. HardwareKeys Enumeration
http://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.hardwarekeys.aspx
MSDN. HardwareButton Class
http://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.hardwarebutton.aspx
0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33667251
I will try WM_SYSKEYDOWN. And DesktopExplorerWindow too. I'm ready to try anything :)

Re. hardware keys - that's what I was looking in the registry for - but didn't find it on HTC HD Mini. I'll recheck tomorrow, and with other HTC models.

Thanks for suggestions, one of them might resolve the problem.
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33667272
Good luck!
0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33672459
ok, recent update:

DesktopExplorerWindow partially worked, ie if I'm not in any screens available from Today screen then SetForegroundWindow() does the trick, like from Menu screen or normal applications.  But...if one is located in eg Contacts - the one you can start from today screen - then it looks like it DesktopExplorerWindow is already at the foreground, and it stays where it is
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33672904
You wanted to simulate the keyboard input?
Do you remember this trick about SetForegroundWindow:
SetForegroundWindow((HWND)(((ULONG) hwnd) | 0x01) );

It's from MSDN: http://msdn.microsoft.com/en-us/library/aa923858.aspx
 
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 24

Author Comment

by:alexey_gusev
ID: 33674297
doesn't make any difference unfortunately.

HTC has a carousel on its desktop window, so from that point of view it's already foreground.

But maybe I need to explain the problem better.

I have a client/server system, kind of remote control, so the client side shows the skin for the phone, and once the user clicks on the button (Home in this case) this key code is sent to the server (running on the HTC device) and injected. Most of such keys work just fine with keybd_event() or PostKeybdMessage() (didn't try SendInput yet).

I'm fine with any solution which gives me a robust way of mimicking Home button click on HTC. The final result has to be Today screen via whatever trick it is (if any) achievable. If it's possible and necessary to talk directly to the driver I'm glad to give it a go - just tell me how :)
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33674845
I'm sure this way with GetDesktop and SetForeground worked fine for me on HTC Touch Pro 2 - it also had this Touch Flo guy (that blocked Open GL for me). I will check now on another computer.

0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33675142
I have a trivial code. :(
HWND top = ::GetDesktopWindow();
if (top != NULL)
   ::SetForegroundWindow(top);

Probably, you are right and I've never tested this code with a Contacts app running.

0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33675212
Yes, the difference between htc HD pro and mini is that mini has 5 buttons. 4 of them work, but 5th does not
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33675378
>>but 5th does not
:)
0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33675564
DesktopExplorerWindow has few child windows, I've even tried each one in turn for messages with Spy++ - nada, no one received anything when I press Home :|

Do you know that is the window on WM6.5 which holds the menu (with all its icons)? It has Today icon I could try to 'click'. Or alternatively maybe there is some control panel applet for Today icon.

I'm iterating though all possibilities however insane they might sound :)

Good guys at HTC support told me my device is faulty... :)
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33675644
No, I do not remember already.
I thought that in a separate full-screen app you can catch any keyboard event. So Home button never works? Or it does not work for your app?
0
 
LVL 24

Author Comment

by:alexey_gusev
ID: 33675771
no no, I can catch it in a keyboard hook, but it's not my goal.

I want to simulate the click on it, ie inject the button click sent from the desktop. As a result one should see Today screen.

So it's not about catching the click, but about injecting it. I have a service running and listening to client's connections, then the client sends 'key press' to the service and it has to inject it - that's kind of remote control system for mobile phones.
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33676092
very strange. :(
if you can catch, why you cannot send the same? Directly to the desktop window, for example. Or broadcast it. But you are right. keyb_event should work and only HTC guys may help. Probably, they made something strange about this button.
0
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 0 total points
ID: 33689958
OK, after some spent in Spy++-ing, thinking and googling, I've finally realised that what I see on HTC is manila.exe. Better later than never :)

So, all one has to do is to launch "\Windows\manila.exe" with some command line parameters, and this link provides a good reference:

http://forum.xda-developers.com/archive/index.php/t-416688.html

In case of home page, it's just

PROCESS_INFORMATION pi;
CreateProcess(_T("\\Windows\\manila.exe"),_T("--switchtopage home.page"),NULL,NULL,FALSE,0,NULL,NULL,NULL,&pi);

So at the end of the day it's as simple as that :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fibonacci challenge 11 84
count8 challlenge 13 86
Microsoft C++ code failing in executable that worked 9 54
Base1 Encode/Decode 3 31
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now