C++ mouse click on certain spot in window
c, c++, winapi
Solution
Use `SendInput()` instead, then you can use flags to move the cursor relative to the window -
`Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;`
- How i can simulate a double mouse click on window ( i khow handle) on x, y coordinate, using SendInput?
- http://www.cplusplus.com/forum/windows/97017/
Problem
I have my function here working, but I am certainly going about it the wrong way. My program uses FindWindow to find the correct window. I need to double click on a specific location on this window. I made it work by always putting the window in the same location on the screen, but if I moved the window the program would try click on the hard-coded location I have provided and it would not work. Here is the function: ``` void lobbyWindow(HWND main_client) { //RECT arect; // GetWindowRect(main_client, &arect); SetCursorPos(748,294); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } ``` As you can see I just move the mouse to 748,294 and double click. What I want to do is set the mouse to 100,100 in the main_client window, so if I move the main_client window the mouse still clicks on the correct spot.