Sign in to follow this  
Froztwolf

[.net] "external" shortcuts

Recommended Posts

Hey hey. Im writing a small text-management C# proggie that sits in the system tray and the idea was to be able to paste text from it through external shortcuts. Example: You have your email program open in front of you and press alt+ctrl+n to paste your "sorry-no jobs available" reply that you wrote months ago and don't feel like writing again three times a day. Or maybe you keep answering the same questions on msn. ctrl+alt+r for your standard reply. My point is, does anyone know whether such "external" shortcuts are possible and if so, where would I find info on using them?

Share this post


Link to post
Share on other sites
ScreenCap sits in the system tray and takes screenshots when you press a key. Although it is completely different then the program you are trying to create, it comes packed with a neat keyboard event listener class. The source is available from the website.

Share this post


Link to post
Share on other sites
You would have to get the handle of the focused window, the handle of the text control and preform a paste to it.

That is what I think anyways. Certainly do-able.

Share this post


Link to post
Share on other sites
Cheers guys. I'm going to check out Screencap to see how they do it and see if I can utilize Windows Hotkeys.
Getting the handles of a focused window and the text control should be possible, if not easy, right?

Share this post


Link to post
Share on other sites
I use the following to get the handle of the focused window:


using System.Runtime.InteropServices;

[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();



I would bet that you could either find a function to get the window the caret is focused in or get the active child of the foreground window.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this