[.net] "external" shortcuts
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?
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.
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.
That is what I think anyways. Certainly do-able.
Google around for Windows Hotkeys. You'll need to do some P/Invoke with the Win32 API, but it's fully possible.
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?
Getting the handles of a focused window and the text control should be possible, if not easy, right?
I use the following to get the handle of the focused window:
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement