You need to use RegisterHotKey and UnregisterHotKey from the Win32 API, they are very easy to use.
Alternatively, you can find the useful ShortCutToKey () which returns the key code and shift status in the Delphi shortcut.
PS: Do not forget to check the return value of RegisterHotKey (), since it will not be executed if the hotkey is already registered by another application.
Edit : Sorry, although I used a different WM_MESSAGE, since you first placed the code as plain text, and I only looked at it ...
I think the problem with your code is that you are using GlobalAddAtom for the ID key, but you only need to use the unique identifier inside your application (the docs for the function say that you need to use GlobalAddAtom only for the common DLL). Try using only this:
const ID_HOTKEY1=0; ID_HOTKEY2=1; procedure TYourForm.FormCreate(Sender: TObject); begin if not RegisterHotKey(Handle,ID_HOTKEY1,MOD_CONTROL,Ord('1')) then Application.MessageBox('Error registering hot key 1','Error',MB_ICONERROR); if not RegisterHotKey(Handle,ID_HOTKEY2,MOD_CONTROL,Ord('2')) then Application.MessageBox('Error registering hot key 2','Error',MB_ICONERROR); end; procedure TYourForm.FormDestroy(Sender: TObject); begin UnregisterHotKey(Handle,ID_HOTKEY1); UnregisterHotKey(Handle,ID_HOTKEY2); end; procedure TYourForm.WMHotKey(var Msg: TWMHotKey); begin Application.MessageBox(PChar(IntToStr(Msg.HotKey)),'Hotkey ID',MB_OK); end;
In addition, MOD_CONTROL and its associated constants are already defined by Delphi, you do not need to redefine them.