DetourIt

 SDK 

 

MouseClick
 
Sends a mouse click to the specified window.
 
Syntax:
 
void MouseClick(
   HWND hWnd,
   DWORD xPos,
   DWORD yPos,
   DWORD button = MK_LBUTTON
);
 
 
Parameters:
 
 
hWnd
 
            type: HWND
 
            The handle to the control.
 
 
xPos
 
            type: DWORD
 
            The x-coordinate of the mouse click.
 
 
yPos
 
            type: DWORD
 
            The y-coordinate of the mouse click.
 
 
button   (Optional)
 
             type: DWORD
 
             Specifies which mouse button to click with.
 
             Set to MK_LBUTTON (Left mouse button) by default.
 
 
MK_LBUTTON              Left mouse button
 
MK_RBUTTON             Right mouse button
 
 
 
Return Value:
 
 
No return value.
 
 
 
Example:
 
 
#include "detourit.h"
 
void main()
{
 
    //We use FindWindow (a win32 api) to find a Notepad window. 
    //You must have an untitled notepad window open in order for this to work.
    //We leave the classname NULL as we are only interested in the window title.
    //The L before the "Untitled - Notepad" is only for Unicode projects. 
 
    HWND hWndParent = FindWindow(NULL, L"Untitled - Notepad"); 
 
    //Now we need to find the edit-box part of the notepad window.
    //Notice that we use FindWindowEx() here. This is because it is capable of searching
    //for child windows. This time we search for classname instead of window title.
 
    HWND hWnd = FindWindowEx(hWndParent, NULL, L"Edit", NULL);
 
    //We set the x-coordinate to 0 and they y-coordinate to 5.
    DWORD xPos = 0, yPos = 5;
 
    //Mouse button is set to left.
    DWORD button = MK_LBUTTON;
   
    //This will send the Notepad window a left mouse button click to xPos 0, yPos 5.
    MouseClick(hWnd, xPos, yPos, button);
}