Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Why isn't this Working?

Soo, The code below is supposed to print out whenever the keys defined are pressed.
But the opposite happens.

It does not print out the keys pressed, Instead, Only default.

Also, Flush(); is just a function that prints out on the screen.

PHP Code

<?php 
int main
()
{
    
char ikey = 0;
    
//string data = to_string(ikey);
    
while (true) {
        switch (
GetAsyncKeyState(ikey)) {
        case 
up:
            
flush("[UP]");
            break;
        case 
down:
            
flush("[DOWN]");
            break;
        case 
left:
            
flush("[LEFT]");
            break;
        case 
right:
            
flush("[RIGHT]");
            break;
        default:
            
flush("[UNKNOWN-KEY-PRESSED]");
            break;
        }
    }
    return 
0;
} 
(Jul 22, 2018 10:46 AM)F.A.S.T Wrote:  Soo, The code below is supposed to print out whenever the keys defined are pressed.
But the opposite happens.

It does not print out the keys pressed, Instead, Only default.

Also, Flush(); is just a function that prints out on the screen.

PHP Code

<?php 
int main
()
{
 
char ikey = 0;
 
//string data = to_string(ikey);
 
while (true) {
 switch (
GetAsyncKeyState(ikey)) {
 case 
up:
 
flush("[UP]");
 break;
 case 
down:
 
flush("[DOWN]");
 break;
 case 
left:
 
flush("[LEFT]");
 break;
 case 
right:
 
flush("[RIGHT]");
 break;
 default:
 
flush("[UNKNOWN-KEY-PRESSED]");
 break;
 }
 }
 return 
0;
} 
the GetAsyncKeyState function parameter must have one of the Virtual_KEY codes documented here
https://docs.microsoft.com/en-us/windows...-key-codes
[Image: 5Iq5rDJ.gif]

winapi, and winsock programmer



Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by Quality_k1nGSep 27, 2018 07:05 PM 6 292 Sep 27, 2018 07:05 PM
Last Post: Quality_k1nG
[Java] by txkhaarOct 26, 2017 08:19 AM 1 630 Oct 26, 2017 08:19 AM
Last Post: XMR
[C] by JASOct 2, 2017 03:35 PM 33 1,135 Oct 2, 2017 03:35 PM
Last Post: HiddenEyE