winapi - Issue with generating left click in win32 api? -



The following is my code to use win32 api. The problem is that it gets stuck And does not return to the main. When I press Ctrl + c, it comes back to the main. But When I call it twice, imitating the double click, it's okay. Is there any mess in this code? Thank you.

  zero left click (zero) {INPUT input = {0}; // drop down input. Type = INPUT_MOUSE; / * The event is a mouse event, use the union's mile structure. * / Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; SendInput (1, and input, sizeof (input)); // zero memory (& input, size (INPUT)) left; Input. Type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; SendInput (1, and input, sizeof (input)); }    

If you are not committed to using SendInput, then I got success With the previous WM_LBUTTONDOWN using SendMessage with WM_LBUTTONUP on the desired HWW.

Most buttons do simulate a click with keyboard entry, you can use SendMessage with WM_KEYDOWN and wParam VK_SPACE, then WM_KEYUP to complete the space bar pression simulation with VK_SPACE.

Comments