C++ (CLR) mouse click inside a minimized window
In a windows C++ CLR project I am trying to build a function that can send a mouse click to absolute x, y coords in a out of focus / minimized / hidden window.
The function is controlled by pressing a button on the app GUI.
Doing some research on google I put together the code below.
The above code does send a click to the minimized window, but not at specified coords.
The click is sent to the minimized window at the coords of the mouse pressing button on the GUI.
So whereever the GUI is located on the desktop, when I press the button that runs the function, the click is sent to the minimized window at the GUI's button coords.
If I set focus to the window (SetForegroundWindow) sleep a few seconds then perform the code above, it still does not work and the click is sent to the GUI's button coordinates. So i figure there is a problem with the code... as it should have sent the click correctly on the focused window...
Any ideeas on how I can make this code work as intended?
Thanks