Member 8973214 wrote:
Yeah, the following link shows how to create keyboard shortcut in windows to open an application [some irrelevant link, removed — SA], but I want to do this via C# code.
Please see my last comment to Solution 1.
You may want to do it in one of the two ways: 1) you can make some applications listen to some global keyboard shortcut and activate itself; remember that the application cannot start itself; also remember that applications define the shortcuts independently, so the different application may conflict; 2) you can have a separate "manager" application and register some of the applications to be started or activate.
First thing you need to understand, that you are asking about "shortcuts" which has nothing to do with usual shortcuts used inside each application. If you do the Web search,
almost all search results will be about those "regular" shortcuts, not those you are asking about.
In both cases, you will need to use
Windows Hooks:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589%28v=vs.85%29.aspx[
^].
Moreover, in both cases you need to make your hooks
system-global. According to Microsoft documentation, it will require the hook installed in some
native DLL. It means that you cannot do it fully in C#. You can only have the main application in C#, but is should load the native DLL and use it for hook installation. Moreover, the hook is never captures in the same thread. You will need to use some thread-independent way to communication between the hook handler and the application, possibly using IPC (
http://en.wikipedia.org/wiki/Inter-process_communication[
^]).
Got the main idea? Than try to implement it, but I'll warn you: it will be pretty big work, and hook functionality is quite hard to debug. At the same time, I'm pretty sure there are available applications which do pretty much the same. So thing: does it worth it? :-)
—SA