Board index » delphi » Global Hotkey ?

Global Hotkey ?

Is it possible to define a 'global'hot key that can be trapped by
a delphi app even if it doesn't currently have windows foreground?

I need to have a program react to a keypress even if I have several
other app's running at the time.

tia,

Roy.
r...@mechnet.liv.ac.uk

 

Re:Global Hotkey ?


Hi, Roy.

Quote
>Is it possible to define a 'global'hot key that can be trapped by
>a delphi app even if it doesn't currently have windows foreground?

>I need to have a program react to a keypress even if I have several
>other app's running at the time.

Not sure I got exatly what you need, but nevertheless. I've written an
application that works in a hidden state and can be operated via icon on
tray or hotkeys. Even if you're doing something in some other app, pressing
hotkey combination sends m,essage to your app.

I used RegisterHotKey(Handle,idHotKey,modHotKey,vkHotKey);
idHotKey is a result of GlobalAddAtom, modHotkey - Alt|Ctrl|Shift modifiers,
vkHotKey - virtual key (for ex. 123 for F12). Behaviour on hotkey is defined
ind WndProc:

procedure TLead.WndProc(var Msg: TMessage);
begin
  if Msg.Msg=WM_HotKey then
   begin
    if Msg.wParam=idHotkey then DoSomething;
   end
  else
  inherited WndProc(Msg);
end;

I also use UnregisterHotkey and GlobalDeleteAtom to remove what has to be
removed. I think it is what yopu meant to be 'global hotkey'.

Write back if it helps.

Bye.
/lexi

Re:Global Hotkey ?


Eeek... thanks for the info, I'll print it out now and try to digest it
later!

Regards,

Roy.

Quote
lexi <l...@ufanet.ru> wrote in message news:86adv2$k0d$1@www.ufanet.ru...
> Hi, Roy.

> >Is it possible to define a 'global'hot key that can be trapped by
> >a delphi app even if it doesn't currently have windows foreground?

> >I need to have a program react to a keypress even if I have several
> >other app's running at the time.

> Not sure I got exatly what you need, but nevertheless. I've written an
> application that works in a hidden state and can be operated via icon on
> tray or hotkeys. Even if you're doing something in some other app,
pressing
> hotkey combination sends m,essage to your app.

> I used RegisterHotKey(Handle,idHotKey,modHotKey,vkHotKey);
> idHotKey is a result of GlobalAddAtom, modHotkey - Alt|Ctrl|Shift
modifiers,
> vkHotKey - virtual key (for ex. 123 for F12). Behaviour on hotkey is
defined
> ind WndProc:

> procedure TLead.WndProc(var Msg: TMessage);
> begin
>   if Msg.Msg=WM_HotKey then
>    begin
>     if Msg.wParam=idHotkey then DoSomething;
>    end
>   else
>   inherited WndProc(Msg);
> end;

> I also use UnregisterHotkey and GlobalDeleteAtom to remove what has to be
> removed. I think it is what yopu meant to be 'global hotkey'.

> Write back if it helps.

> Bye.
> /lexi

Other Threads