Beranda > Delphi > How to register a global hotkey

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.

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

Example of use:

RegisterHotKey(Handle, 100000 { Any unused number}, MOD_CONTROL, VK_F7);
// When closing program
UnregisterHotKey(Handle, 100000);
Iklan
Kategori:Delphi
  1. Februari 22, 2013 pukul 2:30 am

    Exactly where did u pick up the recommendations to post ““How to register a
    global hotkey ##ats76id##”? Thanks for your time ,Holley

  2. Mei 3, 2013 pukul 6:02 am

    An outstanding share! I have just forwarded this onto a colleague who had
    been conducting a little research on this. And he in fact bought me breakfast because I found it for him.

    .. lol. So allow me to reword this…. Thank YOU for the meal!

    ! But yeah, thanx for spending time to discuss this topic here on your web site.

  3. Juli 21, 2013 pukul 2:40 pm

    Hi outstanding website! Does running a blog similar to
    this take a massive amount work? I’ve virtually no understanding of programming however I had been hoping to start my own blog in the near future. Anyway, should you have any recommendations or techniques for new blog owners please share. I understand this is off subject however I simply wanted to ask. Thank you!

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: