-
key activated script
How do I make a program detect which key is pressed, and depending on the key that's pressed it would execute specific script?
For example, if you press 'h' the script 'Beep(2000,500);' would be activated - but if you press any other keys nothing would happen.
Thanks in advance.
-
Sorry if im wrong because im just starting, but since the CALLBACK function is used each time a key is pressed, cant you put a switch statement in the function to handle the letters you want, then each letter adds special things to a new message.
-
I think I know what you're saying, but how would you do it?
-
Well I was looking through some code, and I couldnt pin point it, sorry im still newbish at this, maybe someone who has more experties could answer this. Try a google search
-
chapter #6 in petzold gives good examples on how to handle WM_CHAR and WM_KEYDOWN messages.
-
-
Thanks, for you'r help guys, I don't know if this is the right way of doing it all I know is that this way works!
Code:
if(GetAsyncKeyState(VK_RIGHT)){ // If right arrow key is pressed...
Beep(2000,300); }
else{}