This post is only for those interested in hard-core deep-level computer programming.
It was driving me crazy that my dear Bohemicus would not 100% work with some online CAT tools… well, it sort of works, it is still very well usable, but not to 100%. And what’s the problem? The problem is that the Ctrl+Insert keyboard combo that is often used to insert text from source to target segment. This is a crutial functionality for Bohemicus, and without it, Bohemicus is somehow limited. It works well if you physically press it on your keyboard, but would stop working when you try to send it as a sendkey from Bohemicus.
This intrigued me a lot…. I even attempted sending physical scancodes to other applications, but to no avail….. and I felt: why in bloody hell would this not work?
Why it doesn’t work …
After endless hours of researching, I found 2 reasons:
1. It seems that Firefox/Chrome/Edge simply block the Insert key. They just decided too many users were annoyed by this INS/OVR feature and so they simply turned the INSERT key off. And it cannot be turned back on. But still, using a PHYSICAL keyboard, it was possible to press the Ctrl+Insert combo to insert text from the source.
2. As it turns out, Windows applications have some means to distinguish between physical and virtual keyboard presses, it’s the LLKHF_INJECTED flag that is raised by Windows everytime an application tries to send a virtual keystroke to some other application…. so this is how applications can identify spoofed keystrokes.
And what it all means for me, the creator of Bohemicus? Basically, I can only see one solution to this problem: write my own keyboard driver that would work in conjunction with Bohemicus so that Windows really thinks this is a real physical keyboard. Hmmm, I have never written any driver…. looks like some studying lies ahead….
Edit (May 12, 2021): Ok, turns out I was wrong. The solution is much more simple. The primary cause of all these problems is the Insert key... There are actually 2 Insert keys on a PC keyboard: 1 is grey in the Insert/Del/Home/End/PgUp/PgDn group, the other one is the Numpad0, in the numeric block. And they have different keyboard scancodes. The grey one must be escaped by the 0xE0 value when sending scancodes. More info can be found in this great article that made me finally realize where the problem was: https://www.michaelwda.com/post/scancodes
This is the piece of code that explains it all:
What it means: In order to send the correct grey Insert key scancode, 2 scan codes must be actually sent: the escaping 0xe0, followed by the actual Insert key scancode (0x52). Also, dwFlags and VirtualKeyCode must be set to 0 when sending the escaping code (0xe0). Took me 3 days to figure this out….
Thank you very much Michael!