Board index » cppbuilder » Application or System shortcuts (FAQ?)

Application or System shortcuts (FAQ?)


2006-11-10 05:39:17 PM
cppbuilder67
Hi all,
I need to hook a keyboard shortcut without exceptions at least at
application level, preferably at system level. I tried both VCL 'tricks' I
know, that is :
- set main form's KeyPreview to true and set OnKeyUp event handler;
- set TApplication::OnMessage handler an respond to WM_KEYDOWN and
WM_SYSKEYDOWN there.
At application level I can hook key press most of the time but not always.
Let say I need to trigger some action when user presses F8. At least when
app's menu is active (e.g. after pressing F10) I do not get keyboard event
at none of event handlers. I assume I have to hook another message when menu
is active at application's message handler but I have no idea which one
(btw, I tried WM_SYSCOMMAND with no success).
Can somebody help with this?
Actually I would like to hook keyboard all the time, even if another
application is active. I know this is a 'no-no' but my application controls
some hardware and at least one "panic" button should be hooked and trapped
into my application even if it is running in background.
Can somebody help with this too?
Thx in advance,
gorc
 
 

Re:Application or System shortcuts (FAQ?)

"Goran Bervar" < XXXX@XXXXX.COM >wrote in message
Quote
Actually I would like to hook keyboard all the time, even if another
application is active.
Then you have to use a global keyboard hook. Look at the SetWindowsHookEx()
function in the Win32 API. Your hook callback has to be inplemented inside
a DLL in order to hook other processes.
Gambit