Windows Mobile 2005, keyboard

I have to write an application, which should work in background, gather keyboard data, and send the new key codes to the foreground window. It is needed for input of cyrilical letters.
Keyboard hooks are not working.
Can you advise a solution

Thank you.


Answer this question

Windows Mobile 2005, keyboard

  • Rachita

    Have you considered writing a Custom Soft Input Panel (SIP)
    This would allow you to enter cyrilical letters directly.

    See: http://blogs.msdn.com/windowsmobile/archive/2005/02/10/370355.aspx



  • sigipa

    I use keyboard hooks on Windows Pocket PC 2003 and Windows Mobile 5. The hook is in my invisible, out of focus window. I can also send a WM_CLOSE message to this same invisible, out of focus window and it closes the program.

    I don't know if sending a WM_CLOSE is different to sending any other keyboard event. It most likely is.


  • Dale17677

    Despite its name NotSupportedException is never thrown because the API is not supported. This exception signifies that the marshaller was not able to marshal arguments. In this case I suggest that you add [StructLayout(Layoutkid.Sequetnial)] to the definitions of keyboardInfo and KBDLLHOOKSTRUCT

  • orouit

    I have already used the sample given in the link above but I get "not supported exeception" on the line where SetWindowsHookEx is called. I executed it in Windows Mobile 5.0 Pocke PC emulator. I assume this means Hook is not supported. Can u provide any info on this.
  • testqh

    Thanks for ur reply.

    I am developing managed application in .Net CF 2.0. In one of your posts

    http://www.pcreview.co.uk/forums/thread-1298033.php,

    I found that

    NotSupported exception is typically caused by an incorrect P/Invoke definition, such as using "long" type or complex
    structures.In case of SetWindowsHookEx it is caused by you attempting to pass a delegate to the P/Invoked function - this is not supported on Compact Framework. The workarounds are either place hook code into unmanaged code or use the approach I described here:
    http://www.alexfeinman.com/callbacks/Callbacks.htm

    The page Callbacks.htm is not found.

     


  • The Tick

    I think you may add PreTranslateMessage,when Key was pressed, send message to background window, let background window to process this message.
  • Michael Klucher - MSFT

    Why isn't the keyboard hook working It still has to be in a program with a message loop, basically a windowed program. You can force this program to run in the background by using ShowWindow(hWnd, SW_HIDE) . You can then use SendMessage to send messages to the approriate window. If you don't have the handle for the window, use FindWindow .

    Is that the sort of stuff you needed to know


  • Bill Gates II

    But I have read that hooks are considered as a privileged API call in Windows Mobile 5.0. BTW have u used SetWindowsHookEx and if yes is it a global hook
  • Sweenie

    The window will not receive keyboard messages unless it has focus. It won't be able to get focus unless it is visible.

    Hooks are not supported under Windows CE



  • NathanInNashville

    Yes, this is a global hook. A sample can be found here: http://www.infusionblogs.com/blogs/ayakhnin/archive/2006/03/05/399.aspx

    On WM 5.0 this API is considered a privileged API (see http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=111354&SiteID=1)



  • Windows Mobile 2005, keyboard