How to setup a keyhook

i have my main function

Main()
{
}

and i want to setup a keyhook or hotkey so when key'd down it will do execute the main()

i tried doing a

if (key == V_main)
{
Main()
}

it all worked fine and dandy but when i try it there is very slight delays which
for the function i need it as fast as possible

i was told my way of keyhooking isnt for functions you need immediate response

what would be the best way

i tried like a sendmessageA but im sure thats wrong
closed account (o3hC5Di1)
Hi there,

main() is automatically called as a starting point for your program, so it doesn't make much sense calling it again. I see that you're using Main() as a name, as opposed to main(), but that's very ambiguous and to be avoided.

You will need to repeatedly check the keyboard (standard) input until a certain key is pressed. When it is, you can trigger the function you like.

Perhaps this function will help you do what you want:
http://cplusplus.com/reference/iostream/istream/get/

Hope that helps.

All the best,
NwN
Topic archived. No new replies allowed.