Program waits for key press after last cout

The issue I am facing is that after a cout is executed in my while loop, it waits for input before executing the next line of code. I want to skip waiting for a keypress, and jump straight to the mouse_event.

1
2
3
4
5
6
7
8
9
while(1){
   cout << "I have to press enter after this line, before the next is executed" << endl;

   mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0); // keypress event
   mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
			
   Sleep(1000);

}
Last edited on
Hello gunman353,

I do not believe the problem is in the while loop but in the "mouse_event" function that you have not shown. The "cout" will not cause the program to wait, so, I suspect that the problem is in the "mouse_event" function.

Hope that helps,

Andy
mouse_event(...) synthesizes mouse events but does not wait for a key pressed. So the problem must be somewhere else (like undefined behavior/crash) and it accidentally occurs there.
Topic archived. No new replies allowed.