«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

How to register a global hotkey


Global hotkeys are very handy when your application should be accessible at all time. For instance, you are browsing the Web and suddenly want to e-mail your friend. The most convenient way to do so would be to press a shortcut and the e-mail client would popup with a "new message" window no matter what program you are using at the time. This can be done with global shortcuts. They are system-wide no matter if the program you are using uses the same shortcut. A global shortcut is more important.

Here's the code to register and unregister a global shortcut.

  Messages, Windows;
  // Your main form's class
    procedure WMHotKey(var Message: TMessage); message WM_HOTKEY;
procedure TMainForm.WMHotKey(var Message: TMessage);
  // This example brings the application up front. Put your code here

Example of use:

RegisterHotKey(Handle, 100000 { Any unused number}, MOD_CONTROL, VK_F7);
// When closing program
UnregisterHotKey(Handle, 100000);
Author: Unknown
Added: 2007-06-02
Last updated: 2007-06-02

« Return to contents »