Link to home
Start Free TrialLog in
Avatar of Alexandre Fernandes
Alexandre FernandesFlag for Brazil

asked on

Visual Basic Console Application Keyboard Hook

Hello, I'm looking for an example on how to implement a keyboard hook to capture certain keys in my CONSOLE app, not forms,

For example: F1 to Help or F10 to exit the app from anywhere.

I found C# examples and Form examples. Can anyone help?

Thanks

Alex
Avatar of ste5an
ste5an
Flag of Germany image

ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alexandre Fernandes

ASKER

Excelent! Thanks
Caveat: a console has not necessarily a keyboard associated. Because it has also not always a window associated

See How To Obtain a Console Window Handle (HWND), GetConsoleWindow function.

You need to "hook" into stdin instead to be save.

See Console Handles.