How to synchronize the text content from the OSD with the host app?
How to retrieve the text from the host app and have it displayied in the OSD?
The text cursor [caret] does not jump between words as the host app.
When I play games, it is plain annoying. How to deactivate it temporarly?
I only want to use this application for its keyboard beepers. How to deactivate the OSD?
The OSD is aligned to the right on the secondary monitor. How to prevent this?
Q: How does this application work?
A: KeyPress attaches [using keyboard hooks] individually to each key and modifier, on your keyboard and listens/waits for these to be pressed. When a key is pressed, it is displayied on the OSD. When typing, it uses Windows APIs to get the key names, based on the current keyboard layout. This applies as well when using Shift, AltGr or Caps lock.
The application does not use the caret specific Windows APIs to detect where the actual text cursor [caret] is in the text field of the currently active application, because most applications do not make use of these APIs - to report the caret position. It also does not detect if a text field is active or not.
In details:
When the script initializes, it goes through all the Virtual Key codes and tests with ToUnicodeEx() and GetKeyName() if there's something to bind to (a key name).
In the language file, I made list of VKs for dead keys, for around 70 keyboard layouts. I made it to bind distinctively to this type of keys. At initialization, the script generates a list of dead key names that later, is used to display the appropriate symbol. One cannot use ToUnicodeEx() each time such a key is pressed, to display their name/symbol, because they no longer function properly in host apps.
The main typing mode hooks to each key using the Hotkey command from AHK, by Virtual Key (vk) and different modifiers. For the Shift and AltGr key combinations, the script binds distinctively, because it must be able to catch these keys orderly and always be able to determine what key name to display using ToUnicodeEx(). if it would bind simply with the (*) wildcard, dead keys cease to function and on slow systems, modifiers detection becomes unreliable. By binding specifically to each modifier and key, based on the prefixes from the built-in variable A_THISHOTKEY, it can always ascertain what to display.
When alternative hooks are enabled, a different thread runs with a Loop for an Input command limited to one character. This input command is able to capture dead keys combinations (accented letters). For each key pressed, I use SendMessage to the main thread of the script, that uses OnMessage for WM_COPYDATA. The function associated processes the incoming messages / keys. What this secondary thread sends is used only after a dead key was pressed. Thus, it all still relies on the Hotkey command to get all keys and ToUnicodeEx(), except for the accented letters (keys resulted from using dead keys). When the layout is supported and no dead keys are present, this secondary thread is never initiated.
When alternate typing mode is invoked, I create a new window and focus it, to capture keys with two OnMessage hooked to WM_CHAR and WM_DEADCHAR. I no longer rely on the Hotkey bindings or Input command from the secondary thread. When the user hits Enter, I use SendInput {raw}. I do not use {text} mode, because I want the OSD to send what the user sees and not have him surprised by getting something else in the host app.
Q: The text cursor does not move in synch with the host app.
A: On slow computers, the host app and KeyPress are more likely to get out of synch, because each application tries to capture key presses simultaneously. If the user types *very* fast, KeyPress is likely to skip the detection of some key presses, especially when using Shift or AltGr. In other cases, on long presses of cursor navigation keys, some applications do not record every key fire.
In such cases, I advise synchronizing often with the host app and typing slower.
Q: How to synchronize the text content from the OSD with the host app?
Q: How to retrieve the text from the host app and have it displayied in the OSD?
A: Use Winkey + Insert. By default, with this keyboard shortcut, KeyPress tries to capture the entire text from the currently active window and text field (through the clipboard) - maximum characters is 950. It sends the following keystrokes rapidly: Ctrl+A [select all], Ctrl+C [copy], Right, End. The two last keystrokes are meant to ensure that the caret is placed at the end of the text.
At "Typing mode" settings window, you can choose a different set of keystrokes by enabling "Synchronize with host app using Shift+Up, Home". When this option is enabled the keystrokes sent are: Shift + Up, +Home [both twice], and then Ctrl+C, and Right - to deselect and place the cursor at the end of the selection. In other words, KeyPress attempts to capture a few lines of text from the current position of the caret.
WinKey + Alt + Insert is the third method provided. The keystrokes KeyPress is sending to the currently active app are meant to capture only the current line while it places the caret at the end of it: End [2x], Shift + Home [2x], Ctrl + C, Left, Right and End [2x].
Q: The text cursor [caret] does not jump between words as the host app.
A: Applications implement inconsistent rules for jumping between words, symbols and numbers with the caret when the user presses Ctrl + Left / Right.
You can try activating from the "Typing mode" settings window the option "Alternative rules to jump between words". With this option enabled, it will mimmick the behavior of Microsoft Word 2016. When the option is deactivated [by default], it mimmicks the rules of Google Chrome.
Q: I can't type letters with accents. Dead keys don't work.
A: Please activate in Preferences > "Typing mode" window the option "Do not bind (ignore) known dead keys". KeyPress will no longer detect when such a key is pressed, thus it is completely ignored.
If this does not work, at Preferences > "Keyboard" settings window, activate "Ignore specific keys" and insert the symbols of the dead keys that do not work and Apply settings.
If this still does not suffice, you can add the Virtual Key code of these keys. Go to Preferences > "Key History" and press the dead key a few times and after, press F5 [to refresh the list of pressed keys]. Copy the code from the first column into the text field of "Ignore specific keys". Put "vk" before each code, for example: vkC0.
And at last, if nothing helps, before typing with dead keys, deactivate KeyPress with Shift + Pause/Break.
Q: Can I paste content from the OSD?
A: Yes, using Ctrl + Shift + Insert. Alternatively, Ctrl + Alt + Insert. This replaces the entire text from the currently active text field.
You must first enable in "Typing mode" settings window the option: "Ctrl+Shift+Insert to paste the OSD content into active text field". This is not enabled by default.
Q: How to avoid exposing my passwords, if I am in public?
A: Before typing passwords, deactivate "Show single keys" with Ctrl + Alt + Shift + F8. This will maintain other features active, such as beepers. Another option is to deactivate KeyPress with Shift + Pause / Break.
Q: What's typed text history?
A: If this feature is enabled at "Typing mode" settings window, on Enter and Escape, the currently written line of text in the OSD is preserved. The two previously recorded lines can be accessed with Page Up / Page Down. This feature is useful to review what you previously wrote.
Q: Can I use Ctrl+Z or Ctrl+V to undo or paste?
A: Yes. Paste works in the OSD even if you deactivate "Monitor clipboard" option from Keyboard settings. Undo is limited to only one level.
Q: When I play games, it is plain annoying. How to deactivate it temporarly?
A: Before starting the game, deactivate KeyPress with Shift + Pause / Break.
Q: I only want to use this application for its keyboard beepers. How to deactivate the OSD?
A: At Main menu > Preferences, select "Never show the OSD".
Q: The OSD is aligned to the right on the secondary monitor. How to prevent this?
A: Activate the option "Never align to the right" at "OSD appearances" settings window from Main menu > Preferences.
Q: How does it make beeps on key presses?
A: It uses sound files for different types of keys. If these are missing, it generates a sound beep that mimmick these sound files. However, the souund volume of generated beeps cannot be changed by KeyPress.
Q: What is Capture2Text?
A: It is the name of another application that specializes in Optical Character Recognition (OCR) on screen. It can capture texts from the screen at the push of a button. It can be customized in many ways.
The KeyPress feature is meant to facilitate the use of Capture2Text. Capture2Text must be configured such that it captures a line of text underneath the mouse cursor when pressing Pause/Break. Please make sure as well that what it captures is stored in the clipboard. When the KeyPress feature is activated, it sends {Pause} every second and it monitors the clipboard. When the clipboard content changes, it displays the content.