Is there a way to grab the send key on Windows Mobile and dial its specific number?

I have a Windows Mobile application using a compact framework (NETCF) that I would like to respond to someone by pressing the submit key and dial the phone number listed in my application. Is there a way to use a compact structure to capture the submit key? I have looked through several articles about grabbing keys, but I have not found one that includes the Submit key.

Update

I found an article describing SetWindowsHookEx as an undocumented API on Windows Mobile. If so, then I really don't want to use it.

SetWindowsHookEx on Windows Mobile

After doing more search, it turned out that the Send key is called Talk in Windows Mobile lingo. Then I found a blog post about using the SHCMBM_OVERRIDEKEY message to signal the OS to send a WM_HOTKEY message to my application when the user presses the Talk key.

Jason Fuller's post on using the Talk button

The blog post and documentation he points to seems to be exactly what I'm looking for. I cannot find a working example and I find a lot of people who cannot get it to work. It also looks like VK_TTALK is not supported in SmartPhones. I'd love to hear from someone who actually works on smartphones and PocketPC phones.

+1


source to share


3 answers


I can confirm that using SHCMBM_OVERRIDEKEY works on both PPC and SP devices. I tested it on WM5 PPC, WM5 SP, WM6 PPC, WM6 SP. I haven't tried WM6.1 or WM6.5 yet, but I kind of assume they have been working since WM6 has worked.

Also, you might need DTMF support during a call?

Since I was writing the LAP-dll, I followed the following page that you might find helpful: Problems with LAP Execution

These examples are in C, so you'll have to translate them to C #.

To customize the capture of the talk key for a specific window, you need to do:

SendMessage(SHFindMenuBar(window_hwnd), 
            SHCMBM_OVERRIDEKEY, 
            VK_TTALK, 
            MAKELPARAM((SHMBOF_NODEFAULT|SHMBOF_NOTIFY), (SHMBOF_NODEFAULT|SHMBOF_NOTIFY));

      

You can turn on / off the trap at any time. It's also easy to disable the trap:

SendMessage(SHFindMenuBar(window_hwnd), 
            SHCMBM_OVERRIDEKEY, 
            VK_TTALK, 
            MAKELPARAM(0, (SHMBOF_NODEFAULT|SHMBOF_NOTIFY));

      

To detect when the Talk key is pressed, you need to lure the WM_HOTKEY message box window into the proc window:

case WM_HOTKEY:
    switch(HIWORD(lParam))
    {
    case VK_TTALK:
        // make ph call
        break;
    }
    return TRUE;

      



To make a phone call, you need to use the "PhoneMakeCall" API:

#include <phone.h>

void MakePhoneCall(const wchar_t* number)
{
    PHONEMAKECALLINFO call;
    memset(&call, 0x0, sizeof(PHONEMAKECALLINFO));
    call.cbSize = sizeof(PHONEMAKECALLINFO);
    call.dwFlags = PMCF_DEFAULT;
    call.pszDestAddress = number;
    PhoneMakeCall(&call);
}

      

For DTMF support during a phone call, you need to track the phone call using SNAPI (I believe there is a C # library to help you with SystemProperty there ).

Setting after starting a call:

  #include <snapi.h>
  RegistryNotifyWindow(SN_PHONEACTIVECALLCOUNT_ROOT, SN_PHONEACTIVECALLCOUNT_PATH, SN_PHONEACTIVECALLCOUNT_VALUE, window_hwnd, callback_window_msg_number /*e.g. WM_APP */, 0, NULL, &phone_call_notify_handle);

      

You will be returned with a window message that you provide when changing the number of calls. You need to read the registry and check that the call count drops to zero. If you need to close the SNAPI handle:

RegistryCloseNotification(phone_call_notify_handle);

      

During the call, send a message to the cprog application using the key that was pressed by the user:

#define WM_CPROG_SEND_VKEY_DTMF (WM_APP+3) // Sends the DTMF tone(s) through to the current call (converting from VKEY to DTMF chars)

  BOOL PhoneSendDTMF(UINT uvKey)
  {
    BOOL bRet = FALSE;
    static HWND s_hwndCProg = NULL;
    TCHAR chDTMF = MapVKeyToChar(uvKey);

    // Attempt to find the cprog window (MSCprog).
    // Try to keep this window handle cached.
    if(NULL == s_hwndCProg || !IsWindow(s_hwndCProg))
    {
      s_hwndCProg = FindWindow(TEXT("MSCprog"), NULL);
    }

    // Send WM_CPROG_SEND_VKEY_DTMF to the CProg window.
    if(NULL != s_hwndCProg)
    {
      bRet = BOOLIFY(PostMessage(s_hwndCProg,
                              WM_CPROG_SEND_VKEY_DTMF, (WPARAM)chDTMF, 0));
    }

    return bRet;
  }

      

+2


source


You can catch all keys in the worlds (except CTRL + ALT + DEL on the desktop) with the keyhook:

static extern IntPtr SetWindowsHookEx (HookType hook, HookProc callback, IntPtr hMod, uint dwThreadId);

You can use this (or one of the other overrides) in CE via coredll.dll (instead of user32).



However, this is not in the .NET Compact Framework and requires P / Invoke. The best joy of the "free" key press is Form.KeyPreview = true; and it only gives you the keys that get hit when the form is focused, and sometimes has nothing when dealing with devices that have special keys (perhaps your "submit" for example) as I had a similar situation with the "Application1" key on Intermec one a back).

There is, however, one fantastic alternative, I believe OpenNETCF either already does or rolls up very soon with keyhook (via the WinAPI call above), exposing a delicious managed wrapper. Joy!

If it's not ready yet, there are tons of articles and code that demonstrate how to use this via Google, so in the worst case you should be able to find something if you do a search like this . Perhaps something like this ?

+2


source


Are there any specific arguments for using an unassigned PhoneMakeCall ? It is available for smartphones and up to Windows Mobile 6 Professional.

Edit: I misunderstood the question a little. Now I see that you want to trap the event. However, I left my answer for reference.

0


source







All Articles