Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Mobile Development: another keyboard hooking tool: keyToggleCtrl

0.00/5 (No votes)
3 Aug 2010CPOL2 min read 11.1K  
An application that works in the background using a keyboard hook.

Introduction

This is again a keyToggle application - an application that works in the background using a keyboard hook.

After keyToggleCtrl has been started, it will install a keyboard hook and watches the keyboard messages for the appearance of the toggle, or as I call it, the sticky key.

When the sticky key is detected, keyToggle Ctrl will watch the keyboard messages for the keys listed in a keytable (default is watching for presses of the number keys 0 to 9). If the pressed key matches a key in the keytable, keytogglectrl will remove the message from the window message queue and instead send the key found in CharTable with Control pressed before and released after the replaced key.

For example, you press the sticky key, the LED defined by LedID should light and if you then press 0, keyToggleCtrl will send instead Control+C to the active application.

KeyTest3AK IMAGE

Without keyToggleCtrl, you have to show the SoftwareInputPanel (SIP), tap the [Ctrl] button and then the ā€˜Cā€™ and then hide the SIP. With keyToggleCtrl, you can just use the hardware keyboard and have Ctrl+C (Copy to Clipboard) and Ctrl+V (Paste from Clipboard) at your fingers.

After you started keyToggleControl, you will only notice a small symbol on the Today Screen of your device. If you tap the symbol, you have the chance to end the keyboard hook and the keyToggleCtrl application.

KeyToggleCtrl Today Screen

Default key mapping with use of -writereg:

Keytable 0 0x30 -> 0x0043, '0 -> 'C'
Keytable 1 0x31 -> 0x0058, '1 -> 'X'
Keytable 2 0x32 -> 0x0057, '2 -> 'W'
Keytable 3 0x33 -> 0x0054, '3 -> 'T'
Keytable 4 0x34 -> 0x0045, '4 -> 'E'
Keytable 5 0x35 -> 0x0058, '5 -> 'X'
Keytable 6 0x36 -> 0x0057, '6 -> 'W'
Keytable 7 0x37 -> 0x0054, '7 -> 'T'
Keytable 8 0x38 -> 0x0045, '8 -> 'E'
Keytable 9 0x39 -> 0x0056, '9 -> 'V'

These values are the same as ANSI codes or VK_ values found in winuser.h.

  • Default sticky key is VK_PERIOD
  • Sticky timeout is 3 seconds
  • Autofallback is 0
  • LedID default is 1

To find a usable LedID, you may use another tool called LED_Control. Funny, the vibrate motor is also controlled with the same LED API calls.

LED_control IMAGE

<!-- Social Bookmarks BEGIN --> <!-- Social Bookmarks END -->

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)