Hello all, my apologies if this belongs in the window's subforum; it's C++ I just couldn't decide which one it fit better.

My current code detects clicks just fine:

Code:
//this is just in a main function
  USHORT status;
  POINT mousin;
  while(true){
    status = GetAsyncKeyState(VK_LBUTTON);
    //if the button is currently down or has been pressed down 
    //since the last check (??)
    if((( ( status & 0x8000 ) >> 15 ) == 1) || (( status & 1 ) == 1)){
      GetCursorPos(&mousin);
      cout << "Detected a mouse press at "
           << mousin.x << " "
           << mousin.y << " "
           << endl;
      
      //When detected, we need to eat all the other detected messages
      while((((( status & 0x8000 ) >> 15 ) == 1) || (( status & 1 ) == 1)))
        status = GetAsyncKeyState(VK_LBUTTON);
    }
  }
The issue is that when I gobble up those extra "detected" messages it starts to really mess with other programs as they don't seem to get the "released" signal at the end of the mouse click. I imagine there's a better way to eat those signals in the second while loop.

If someone could tell me why this is doing this so I could have it run in the background that'd be spectacular! I'm attempt to mouse-log in order to help me to create automated GUI tests out of actual manual tests.


EDIT: I added a Sleep(100) message at the beginning. The issue seems to have been the granularity at which I was checking. I had tried other sleep statements but decided to keep messing with it.