Avatar of Alexandre Fernandes
Alexandre Fernandes
Flag 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
Visual Basic.NET

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon
ste5an

ASKER CERTIFIED SOLUTION
it_saige

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Alexandre Fernandes

ASKER
Excelent! Thanks
ste5an

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes