2

I'm developing an application to help the user write common text faster.

What I have in mind is a Windows app where the user can configure his key combinations, so that when he's, for instance, writing an email on Outlook or Gmail, he just has to press those keys and the text he configured before will be pasted into whatever app he's using.

So, instead of a user having to write "Dear sir, your order has been received succesfully" every time he receives an order and wants to send a confirmation email, he could just press something like "Crtl + O + R", and the corresponding text will be written for him.

I think that in order to achieve that my app has to do two things:

  1. Intercept the key combination pressed buy the user when he's focused on a different app.
  2. "Paste" the corresponding text to that app.

I have no real clue on how to achieve this, because what my app will be doing is something like "pasting" text on another app (otlook, word, notepad or whatever thing a user can type into), replacing the short text the user wrote with the long text he defined.

Any suggestions? I've looked into hot keys, but I'm not sure they're the way to go, and I also have no idea on how to "paste" the new text.

Thanks.

Hugonne
  • 23
  • 2
  • Searching is your friend: you need to [Register a hotkey](http://stackoverflow.com/questions/496913/register-hotkey) and [Insert text into the textbox of another application](http://stackoverflow.com/questions/4539187/insert-text-into-the-textbox-of-another-application) :-) – Fredrik Mörk Feb 23 '11 at 17:02
  • @Fredrik `SendInput` would be a better way to "paste" the text, because the other app may not be using a control that can accept `WM_SETTEXT` – David Heffernan Feb 23 '11 at 17:11

1 Answers1

0

Have you considered simply adding text to the clipboard? Show the text next to a button that says "Copy to clipboard", and the user can just grab it and click Ctrl-V.

Can't think of a Windows app that does it this way, but I know it's possible; heck, Bit.ly can do it from your browser.

Justin Morgan - On strike
  • 30,035
  • 12
  • 80
  • 104
  • Adding the text to the clipboard might be a good option. Would there be a way to automatically paste it? Like pressing Ctrl + V for the user. – Hugonne Feb 23 '11 at 19:08
  • @Hugonne: It would be hard to come up with something shorter than Ctrl-V, and if you try to do it without the user pressing anything, you'll introduce all kinds of complexity (deciding where to paste, sending input to other apps you don't know about, etc.). I won't say it's impossible, but I certainly don't know how you'd go about it. Depending on what you want to do, hotkeys might be a better option. I'd forget the idea of intercepting input to other apps, though--it just feels like it raises security questions. – Justin Morgan - On strike Feb 23 '11 at 19:58
  • You might be right. The Crtl + V aproach might work, at least while I look up for a more automated process in "version 2". Thanks. – Hugonne Feb 23 '11 at 21:46