Aqua-Soft Forums: Hooking Keyboard Via Windows Api In Delphi - Aqua-Soft Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Hooking Keyboard Via Windows Api In Delphi Rate Topic: -----

#1 User is offline   ashiqman Icon

  • Group: Member
  • Posts: 2
  • Joined: 13-October 09

Posted 15 October 2009 - 11:17 AM

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;
to
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
0

#2 User is offline   matonga Icon

  • Group: Developers
  • Posts: 1,286
  • Joined: 04-September 06

Posted 30 December 2009 - 09:07 PM

Maybe this helps:

http://msdn.microsof...309(VS.85).aspx

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);
begin
	If msg.ID = 100 Then
		Show;
end;


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.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic