under Windows: GetAsyncKeyState-API
No. not
global. That was asked and see my code.
[edit] here's the pascalized example from msdn:
{$mode objfpc}
uses windows, messages;
const NO_REPEAT = $4000; // Marco? missing....
var
msg:Tmsg;
begin
if RegisterHotKey(0,1,MOD_ALT or NO_REPEAT,$42) { $42 is 'b'} then
writeln('Hotkey ''ALT+b'' registered, using MOD_NOREPEAT flag');
while GetMessage(msg, 0, 0, 0) do
if msg.message = WM_HOTKEY then
writeln('WM_HOTKEY received');
end.
Note this does not UN-register here, and you should do that, This is simply the Pascal version of that example on msdn.
Run this program in a console, start another one, whatever, and the alt-b key will be globally intercepted.
Don't worry about the loop, that is OS scheduled...
If you want to do it from a GUI application, follow my steps as described above.
For Windows this is really simple, any tips to make it cross-platform would be appreciated.
(Last time I did such code was TSR time..)