tags:

views:

59

answers:

1

How can I detect one or combination of strokes of keys in ANSI C and/or with Win32 SDK?

For example: how can I detect CTRL+ALT+DEL was pressed?

Please provide me with some source code or any web-link.

Please note that, I am using polling mechanism, not event.

I need to do it in win32 console mode.

+1  A: 

With ANSI C it is impossible, since ANSI C doesn't define any method to access the keyboard in this manner. The lowest-level function in it that takes input from the user is getc that returns a character after it has been entered into stdin and ENTER has been pressed.

As for the Win32 API, indeed this can be done. In the message handling function (WndProc)you should watch for WM_CHAR messages. Modifiers will help you see if CTRL and SHIFT are pressed.


P.S. just a thought, maybe what you're looking for is a tool like Autohotkey?

Eli Bendersky
I need to work with main() not WinMain(). Can you please provide me with any solution?
JMSA