HotKeyManager is a component that allows you to add system hotkeys to your application.
A hotkey in Windows is a key combination which invokes a specific action. You can often use Ctrl+S from an application to save a file. However, a system hotkey allows your app. to invoke a custom action from anywhere. Your app. doesn't have to be in the foreground or even visible. The best known example of a system hotkey is probably Ctrl+Alt+Delete which pops up a system dialog.
AddHotKey | function AddHotKey(HotKey: TShortCut): Word; Registers a hotkey with a specific key combination. NOTE: A return value of 0 means the specified key combination is already in use. |
Returns an index or 0 if error |
ChangeHotKey | function ChangeHotKey(Index: Word; NewHotKey: TShortCut): Word; Changes a hotkey to a new key combination. Provide the index received from AddHotKey as parameter. NOTE: This method returns a new index. The old index is no longer valid. |
Returns an index or 0 if error |
RemoveHotKey | function RemoveHotKey(HotKey: TShortCut): Boolean; Unregisters a hotkey by its key combination. |
Returns true or false |
RemoveHotKeyByIndex | function RemoveHotKeyByIndex(Index: Word): Boolean; Unregisters a hotkey by the index received from AddHotKey. |
Returns true or false |
ClearHotKeys | procedure ClearHotKeys; Unregisters all registered hotkeys. |
OnHotKeyPressed | type TOnHotKeyPressed = procedure(HotKey: TShortCut; Index: Word) of object; Fired when then user presses one of the registered hotkeys. The event method provides the key combination pressed and the index the hotkey is registered under. |
HotKeyAvailable | function HotKeyAvailable(HotKey: TShortCut): Boolean; Tests if the specified key combination is available for registration by your app. (or any other app.). |
Returns true or false |
SeparateHotKey | procedure SeparateHotKey(HotKey: Word; var Modifiers, Key: Word); Splits a key combination into a key (A, for instance) and its modifiers (shift, ctrl, alt, win). |
CtrlFound := (Modifier and MOD_CONTROL) <> 0; AltFound := (Modifier and MOD_ALT) <> 0; ShiftFound := (Modifier and MOD_SHIFT) <> 0; WinFound := (Modifier and MOD_WIN) <> 0; // Special Windows key
Get the latest version from http://www3.ewebcity.com/troels/delphi.asp.
Troels Jakobsen
delphiuser@get2net.dk