Posts tagged ‘keyboard’

KeyWedge: Updated

Hello

at KeyWedge I posted my code that connects to a serial port and then simulates keystrokes into your application.

Now, there were issues where the reconnect did not automatically take place after a Suspend/Resume and you had to invoke the main window and select File-Hide just to let KeyWedge reconnect. This happens on devices that provide the communication port all the time and dont close it during a suspend.

I have added some code to watch the Windows Mobile Power Message Queue for RESUM messages and then do an automatic reconnect. The other option would have been to send some data thru the port periodically to check if it is still working. But this may disturb the attached the device.

The main change is in PowerMsgQueue.cpp. It implements the msg queue to receive power broadcast messages like done in a MSDN example code. If a resume message is encountered, the code sends a WM_USER message to the main window, which will do a SuspendComm/ResumeComm cycle. Very easy.

In PowerMsgQueue.cpp we have code that recognizes the resume:

                case PBT_TRANSITION:
                    nclog(L"Power Notification Message: PBT_TRANSITION\n");
                    //Add2Log(L"Power Notification Message: PBT_TRANSITION\n",TRUE);
                    nclog(L"Flags: %lx\n", ppb->Flags);
                    nclog(L"Length: %d\n", ppb->Length);
                    wsprintf(szPBtype, L"trans.: ");
/*
Flags: 12010000
Length: 6
trans.: ON|PASSWORD|BACKLIGHTON|
*/
                    if(ppb->Flags & 0x12010000)
                    {
                        nclog(L"PwrMsgQueue: got 'ON|PASSWORD|BACKLIGHTON'...\n");
                        //send a message to main window
                        iPost = PostMessage(hwndMain, WM_USER_RESUMECOMM, 0, 0);
                        nclog(L"PostMessage WM_USER_RESUMECOMM returned %i\n", iPost);
                    }
                    break; 

                case PBT_RESUME:
                    nclog(L"Power Notification Message: PBT_RESUME\n");
                    //Add2Log(L"Power Notification Message: PBT_RESUME\n",TRUE);
                    wsprintf(szPBtype, L"resume: ");
                    //send a message to main window
                    iPost = PostMessage(hwndMain, WM_USER_RESUMECOMM, 0, 0);
                    nclog(L"PostMessage WM_USER_RESUMECOMM returned %i\n", iPost);
                    nclog(L"Power: PBT_RESUME\n");
                    break;

To not block the queue, I use PostMessage to inform the main window of the Resume. Here is the simple code block in WndProc of the main window:

Continue reading ‘KeyWedge: Updated’ »

KeyToggleStart: Yet another usage for keyboard hook

Hello Windows Mobile Users

recently the following was requested:

How can I start an application by just hitting some keys in sequence?

The answer: Just use a keyboard hook.

So I started to code this hook tool based on my KeyToggleBoot2 code. There was not too much to change. The new tool is called KeyToggleStart and it is configured by the registry:

            REGEDIT4

            [HKEY_LOCAL_MACHINE\Software\Intermec\KeyToggleStart]
            "ForbiddenKeys"=hex:\
                  72 73 00
            ;max 10 keys!
            "KeySeq"="123"
            "Timeout"=dword:00000003
            "LEDid"=dword:00000001
            "Exe"="\\Windows\\iexplore.exe"
            "Arg"=""

Reg keys meaning:

Forbiddenkeys is just an addon feature: key codes entered in this list will not be processed any more by your Windows Mobile device. For example, to disable the use of the F3(VK_TTALK) and F4 (VK_TEND) keys you have to enter a binary list of 0x72,0x73,0x00 (the zero is needed to terminate the list).

KeySeq list the char sequence you want to use to start an application. For example if this is the string “123”, everytime you enter 123 in sequence within the given time, the application defined will be started.

TimeOut is the time in seconds you have to enter the sequence. So do not use a long key sequence as “starteiexplorenow” and a short timeout (except you are a very fast type writer). The timeout is started with the first char matching and ends after the time or when you enter a non-matching char of the sequence.

With LEDid you can specify a LED index number. LED’s on Windows Mobile are controlled by an index number, each LED has one or more ID assigned to it. So, with LEDid you can control, which LED will lit, when the matching process is running. You can even find an ID to control a vibration motor, if your Windows Mobile device is equipped with one.

The Exe registry string value is used to specify which application will be started when the key sequence is matched.

If the application you want have to be started needs some arguments, you can enter these using the Arg registry value.

When you start the KeyToggleStart tool, you will not see any window except for a notification symbol on your Start/Home screen of the device.

If you tap this icon (redirection sign) you have the chance to end the hook tool.

Continue reading ‘KeyToggleStart: Yet another usage for keyboard hook’ »

ITCKeyboard: a class to manage ITC keyboard mappings

Although Intermec provides a control panel and an API to remap keys for Intermec Mobile Computers these tools only support normal remappings. This means for example you can remap a hardware key to produce a virtual key code. But you cannot map a key to the other great possibilities of the keyboard driver:

  • switch the keyboard plane (shiftkey)
  • map as modifier key
  • map as rotate key (one that produce abc depending on how often you press is)
  • multikey that produces a sequence of key strokes
  • event key, one that fires a named event pair (like the scan button does)
  • a function key that executes a function inside a DLL

I also added classes to manage the used tables as for example MultiKeys, ShiftKeys, RotateKeys, ModifierKeys and so on.

As an example on how the the USB codes are layed out on a device. Unfortunately I only have mappings of this device and not for the others. Therefor you can only suggest the key to remap by the printing on the key.

There is no support in the Intermec tools to remap directKeys. For example the side buttons of a CN3 or CN4 or the PTT button of the CK3 are not managed via the usb keyboard driver, these are managed by a direct keyboard driver. ITCKEYBOARD enables you to remap this keys thru an API.

Continue reading ‘ITCKeyboard: a class to manage ITC keyboard mappings’ »

keyToggleChar – a tool to enter UTF-8 national chars via keyboard

As you may know my keyToggle app to be able to use the number keys on a windows mobile device as function keys, here is another one that enables you to enter special national chars, like Å, Ä Æ etc. directly via the keyboard. You must specify 10 keys and there UTF-8 replacements. Configuration is done via the registry:

3.0        added code for read/write reg for CharTable and KeyTable
 REGEDIT4

 [HKEY_LOCAL_MACHINE\Software\Intermec\KeyToggleChar]
 "KeyTable"=hex:\
 30,31,32,33,34,35,36,37,38,39
 "CharTable"=hex:\
 C6,00,E6,00,D8,00,F8,00,C5,00,E5,00,C2,00,E2,00,C4,00,E4,00
 "LEDid"=dword:00000001
 "autoFallback"=dword:00000000
 "Timeout"=dword:00000003
 "StickyKey"=dword:00000074

 KeyTable     holds a list of 10 keys which will be 'remapped'
 CharTable    holds  list of UniChar codes to use as replacement
 LEDid        defines the ID of the LED to use for showing sticky state
 autoFallback defines, if the sticky state is reset after a mapped key is pressed.
              Use 0, if you dont want the sticky state to fallback after keypress
 TimeOut      defines a timout after which sticky state will be reset

To get the UTF-8 word entries for Unicode chars, see for example here: http://www.unicode.org/charts/charindex.html

The default mapping used here is defined as follows and maps the keys 0-9 to:

0x00c6, 0x00e6, 0x00d8, 0x00f8, 0x00C5, 0x00e5, 0x00c2, 0x00e2, 0x00c4, 0x00e4
 AE        ae     O/       o/      A°      a°      A^      a^      Ä       ä

The main problem I had was finding a function to get the window handle of the current input active window. Finally I found GetForegroundKeyboardTarget() (after some days of searching).

Continue reading ‘keyToggleChar – a tool to enter UTF-8 national chars via keyboard’ »