1

I want to create a Winform that assists me in typing Old English characters. Some of them I can access using the US International Keyboard, but there are some that I can't and don't have working Alt-Codes on Windows, like characters with macrons (āēīōū), ash with macron (ǣ) and characters with dots above (ċ and ġ). (If you do know an easier non-programmatic way to do this, much obliged if you let me know.)

So I want to create a program which I can open and then run, and allows me to do two things:

  1. When I have a textbox selected in any program (Chrome, Word, Notepad etc.) I can press a button on my program without losing focus, and generate the character associated with that button in the relevant program. (Essentially I want to replicate the Windows On-screen keyboard with a specific subset of characters)

  2. When I have a textbox selected in any program, I can press a specific key-combination (e.g. Alt-C or RightAlt-G) that would generate the special character in the textbox.

I'm struggling with both steps, so I'll start with the first one. How can I print a character in another program on pressing a button (I couldn't find this by Googling,) and how can I keep the focus on the program I'm in, to ensure that when I press the button, my program doesn't become focused?

Here's my form layout:

enter image description here

I'm using VB.NET and Windows Visual Studio 2015.

Lou
  • 2,200
  • 2
  • 33
  • 66
  • 1
    To make a form unfocusable you can override `CreateParams`. [**The bottom of this answer**](http://stackoverflow.com/a/157843/3740093) can be easily converted into VB.NET using an online converter. – Visual Vincent Dec 17 '16 at 02:56
  • 1
    As for printing the character, use [**`SendKeys`**](https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx). And finally, [**hotkeys**](http://stackoverflow.com/a/38154826/3740093). – Visual Vincent Dec 17 '16 at 02:59
  • Okay, I'm having trouble with SendKeys. I've looked around several answers and haven't been able to get anything working the way I want it. All I could find was [this answer](https://social.msdn.microsoft.com/Forums/en-US/9787352e-6320-43a6-8644-83a29fe27e7b/sending-keys-to-inactive-window?forum=Vsexpressvb), which allowed me to set the text in a Notepad window, but I want to append (not reset) text in any application. – Lou Dec 18 '16 at 23:39
  • `SendKeys` sends key presses to the currently focused window. If you follow my first comment and make your form unable to receive focus that causes the previous app to retain its focus, thus `SendKeys` should work without a problem. – Visual Vincent Dec 19 '16 at 00:04
  • You should only need to use one line: `SendKeys.Send("text or character here")` - no need to deal with getting the right window, if yours can't receive focus anyway. – Visual Vincent Dec 19 '16 at 00:06
  • Oh, wow, was it really that easy? I don't know why I couldn't make that work before... – Lou Dec 19 '16 at 00:23
  • So I assume you got it working? – Visual Vincent Dec 19 '16 at 00:31
  • I did, yeah. All these complicated answers and it was the simplest solution that worked! I still haven't figured out the HotKeys thing, but that's step 2, I'll get there. – Lou Dec 19 '16 at 01:36

0 Answers0