When I use the GetAsyncKeyState function, it locks the key after I've used it. Example:
if(GetAsyncKeyState(VK_SHIFT)) {
std::cout << "shift pressed!" << std::endl;
}
After executing above code I press shift, get the message and close the console program down (press X). Then, if I press something such as the explorer in the menu bar on windows, it opens a new window of itself. It only does this if you hold shift on it and press it. This event of "things acting like I'm holding down shift" applies to EVERYTHING after I run the above code, and press shift however many times. I've tried changing the if statement to
if(GetAsyncKeyState(VK_SHIFT)&1) {...}
and
if(GetAsyncKeyState(VK_SHIFT) < 0){...}
which doesn't change anything. If I use GetKeyState I get the wrong key state. The issue persists with GetKeyState as well. The issue persists if I use they shift key inside the console AND outside the console. However, the issue is not present BEFORE I close the console window with my code running in it. How do I escape this?
Aucun commentaire:
Enregistrer un commentaire