views:

275

answers:

5

How do i write a windows application that listens to particular keys strokes to launch it! just the way google desktop app works,press ctrl twice and it pop up!

I would prefer examples in delphi, but i dont mind other languages to!

For starters i assume it should be a service running in windows (i can be able to create a service application)

Gath

A: 

You could write it as a service if you wish with its own message pump, capturing all windows messages, checking those that are related to key presses and not passing them on to the default message handler.

My Delphi is very rusty (version 4), so I can't say how to do it.

An easy alternative to writing a service, in C# would be to set an application form with Opacity of 0%, KeyPreview = True and ShowInTaskbar=False.

Maybe your version of Delphi has something similar.

ChrisBD
Does setting KeyPreview make the window receive ALL keyboard events from the system? I doubt it. It just makes the window receive keyboard events before the controls on that window, the same as Delphi's KeyPreview property. That makes it no good for Gath's problem.
Rob Kennedy
Quite true.I'll admit that I posted without thinking. Damn cold giving me a definite case of fuzzy logic. Sorry.
ChrisBD
A: 

make a service that install global keyboard hook .

avar
Why would it need to be a service instead of an ordinary program?
Rob Kennedy
+2  A: 

http://www.delphitricks.com/source-code/windows/install_a_keyboard_hook.html

http://delphi.about.com/od/windowsshellapi/a/keyboard_hook.htm

SimaWB
RegisterHotkey! Don't install a global hook!
Paul Betts
+1  A: 

You are probably better off registering a hotkey instead of installing a gobal keyboard hook:

http://delphi.about.com/cs/adptips2001/a/bltip0601_3.htm

Mo Flanagan
Can you configure a hotkey to respond like Google Desktop Search does to pressing Ctrl twice?
Rob Kennedy
A: 

See HotKeyManager at: http://subsimple.com/delphi.asp

volvox