Search code examples
c#sendkeys

SendKeys and Outlook


While experimenting with SendKeys, I found out that it didn't work when sending keys to Outlook's (2010) message textarea. However, the address bar seems to work just fine. Word is another one (no big surprise as Outlook and Word uses the same editor). I'm sure there are other similar programs which I haven't found yet as well.

Any ideas?

Update: I've narrowed this down to only be about characters which require AltGr to type (Swedish keyboard layout) i.e: @£$€{[]}\~


Solution

  • When I first tried to replicate your problem, I could not do so. You then updated your question to indicate that the problem lies with the AltGr key.

    A quick scan of the SendKeys documentation seems to imply that there is not support for such an esoteric (!) key.

    I therefore recommend that you switch to using SendInput through P/Invoke. This is morally equivalent to SendKeys and gives you total flexibility to fake just about any input. I wouldn't be at all surprised if there was available C# code to wrap this up for you.