Your own Ctrl+Alt+Del?

You know how in WinXP, pressing Ctrl+Alt+Del always launches the Task Manager no matter what is open or what happens to be in focus?

Is there a way of making another key combination, e.g. Ctrl+Alt+Numpad1, always do somehing (e.g. run a command) no matter what program is open/what's in focus?
[307 byte] By [HighCommander4] at [2007-11-20 10:40:26]
# 1 Re: Your own Ctrl+Alt+Del?
It's called a system wide keyboard hook ( http://www.google.com/search?source=ig&hl=en&q=system+wide+keyboard+hook&btnG=Google+Search). For simplicity, any VB can easily handle it. I am sure that Any C-based language could as well.
PeejAvery at 2007-11-10 3:39:54 >
# 2 Re: Your own Ctrl+Alt+Del?
yeah, any C based language can also do that. It all boils down to what language the OP is using.
If you are using C# or VB.NET, there is a component called MCLHotKey - it really works like a charm.
Here's a link :
http://www.codeproject.com/vb/net/mclhotkeynet.asp?df=100&forumid=15817&exp=0&select=1851704
HanneSThEGreaT at 2007-11-10 3:40:54 >
# 3 Re: Your own Ctrl+Alt+Del?
I am using C++ and I found the API SetWindowsHookEx() to do the job for me. But I don't really understand how it works. MSDN says that for a system-wide hook, the callback procedure that processes the keyboard input must be placed into a DLL. A program then loads the DLL using LoadLibrary(), gets the address of the callback using GetProcAddress() then passes the address to SetWindowsHookEx() to install the hook. But when the program exits - does it not have to call FreeLibrary() on the DLL which means it will no longer be in memory and the hook will no longer be in place? Does that mean that this program that calls SetWindowsHookEx() needs to be running throughout the time I want the hook to be in place?
HighCommander4 at 2007-11-10 3:41:57 >
# 4 Re: Your own Ctrl+Alt+Del?
You can either use WM_SETHOTKEY to set a single hot key that activates your application ( for example ), or you can use RegisterHotKey to register any number of hot keys that can do whatever you want.

WM_SETHOTKEY is associated with your top-level window and main thread whereas RegisterHotKey works with any window and any thread.

That's the approach I'd take.
HanneSThEGreaT at 2007-11-10 3:43:04 >
# 5 Re: Your own Ctrl+Alt+Del?
Thank you, HanneSThEGreaT, for that excellent advice. I finally did, using RegisterHotKey(), in a matter of minutes, something I was struggling to do with SetWindowsHookEx() for days.

:thumb: :thumb: :thumb:
HighCommander4 at 2007-11-10 3:44:02 >
# 6 Re: Your own Ctrl+Alt+Del?
I'm glad that you got it solved, well done ! :thumb:
HanneSThEGreaT at 2007-11-10 3:45:06 >