System-wide hotkeys - how to programmatically define global keyboard shortcuts?

Question

How program to interrogate Win7, to get a list of active active shortcuts all ?

Scenario

Many versions of Windows have a so-called “Windows Key,” also known as a “flag,” “start key,” etc.

Microsoft has a support article called “Hot Keys for Windows,” which lists many of them in the “Microsoft Natural Keyboard Keys” section, and like many others, you should not use a “Windows Key,” such as global Ctrl+ C, etc.

Other keyboard shortcuts can be detected by accident. For example, Windows Key + Left arrowor Right arrowin Win7 moves a focused window around the display and with multiple monitors from one display to the next.

In the settings "options" you can find other keyboard shortcuts, for example, Left- Ctrl+ Alt+ Kby default - "Show KeePass window".

In addition, there may be hardware special keyboard shortcuts, for example, on my laptop, Fn+ F8toggles the lowering of the speakers.

Shortcut Keyboard Shortcuts

When Snagit is running , I configured it as a shortcut, but when Visual Studio (VS) is running, it steals from Snagit . PrtScPrtSc

(a) , .

(b) VS, VS , , , , VS .

(a), , Windows Logo Key + L, .

(b) , .

+5
1

, . Windows, -, EnumerateHotKeys? , RegisterHotKey, __FindHotKey. , . . C. , , , Windows Vista +.

- . , . , , :

% AllUsersProfile%\desktop% UserProfile%\Start Menu % AllUsersProfile%\ "" % appdata%\Microsoft\Internet Explorer\Quick Launch% appdata%\Microsoft\Internet Explorer\Quick \User Pinned\StartMenu% appdata%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

, , UserProfile.

using IWshRuntimeLibrary;//You can download this library from http://www.codeproject.com/KB/dotnet/ShellLink/ShellLink.zip


WshShell wsh = new WshShellClass();
var files = GetFiles(Environment.ExpandEnvironmentVariables("%userprofile%"), "*.lnk*");
foreach (string f in files)
{
    try
    {
        WshShortcut wa = wsh.CreateShortcut(f) as WshShortcut;
        if (wa.Hotkey != "")
        {
            MessageBox.Show("Shortcut Found! - " + wa.Hotkey, wa.TargetPath);
        }
    }
    catch
    {
        continue;
    }
}

GetFiles , . , .

.

+2

All Articles