How does this work?!

Posts 1–4 of 4 · Page 1 of 1
How does this work?!
I don't think Im the only one who has been seeing this a lot lately:
Code:
if(GetAsyncKeyState(vk_code)<0)
Now I don't know how in the world this could work, but some how it is returning true when some people press the correct key, when in reality it should always return false. I know some of you are like: "Well if it works who cares?", but this is a problem it shows a serious inconsistency and I would like to find out why. If anyone has any ideas please share them.
Did you try


If 1=true then 0=false,Key1=1,if hit,Key1=0,if hitx2,


/idk what i'm talking about.
Ask BA, he's god o__O
probably because GetAsyncKeyState doesn't function properly on modern computers with their fancy multicores and being able to process way too many shizzle at the same time.
Yes but I dont see how getakeysync could be a problem because ... hmmm hold on a sec....

Testing.... yep thats it!
Code:
#include <iostream.h>
#include <windows.h>
using namespace std;

int main()
{
    while(1)
    {
            cout<<GetAsyncKeyState(VK_SPACE);
            Sleep(200);
    }
    return 1;
}
I forgot GetAsyncKeyState returns a signed WORD value. So it actually returns a negative number when it's pressed because the highest bit is set to 1. That is how the whole < 0 thing works. since GetAsyncKeyState is less then zero when pressed, but goddam why go through so much trouble. any nonzero is true... =/
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us