Jump to content

Hooking Keyboard Via Windows Api In Delphi

Recommended Posts

HI guys

Could anyone point me to the direction of some Tutorials on how to Hook the keyboard usings the windows PAI to capture keystrokes,

I want to enable my App to Bring itself too top if certain key combo is pressed, mainly because i want to give the option for my application to hide <its a to do list app> when user click Hide button. But i have no real way of havign it charm Form1.hide;


Form1.show; unless i can moniter all Keyboard strokes.

I know its posible and have been told not too hard. and i know that it wil lrequire building a DLL, buti just dont know how to code it Thanks

Ad-link removed - mps69

Link to post
  • 2 months later...

Maybe this helps:


Some notes:

HWND -> Form1.Handle

In your form add this to FormCreate procedure:

// For example Win+Shift+A

// 100 or whatever you want, if you register many hotkeys you must put a unique id to each one

RegisterHotKey (Handle, 100, MOD_WIN Or MOD_SHIFT, VK_A);

In your form add this to interface section:

procedure FormHotKey (var msg : TWMHotKey); message WM_HOTKEY;

In your form add this to implementation section:

procedure FormHotKey (var msg : TWMHotKey);
If msg.ID = 100 Then

Of course this is just quick & dirty. For other techniques you'll need a .dll etc... for sure, this is just the simplest alternative.

PS: I didn't test the code, so it may have syntax errors.

Link to post

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
  • Create New...