I am trying to create a code which will detect if the mouse button has been pressed. So far i have a code which will detect if the button has been pressed once. But it isn't letting me check if the button was continuously pressed. For e.g left mouse button pressed, this will start a timer, after 0.5 seconds it will check again and if it is still down output something.
I want to set it up like this
while (true)
{
if (GetAsyncKeyState(VK_LBUTTON) & (0x8000 != 0))
{
cout << ("left button pressed") << endl;
Sleep(500);
if (GetAsyncKeyState(VK_LBUTTON) & (0x8000 != 0))
{
cout << ("Left button held down") << endl;
}
}
}
However, it does not work, it only outputs the second statement if i double click in quick succession.
Determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
The msdn website says that. Does this mean i should check if it is UP after the time to get the result i want.