As Entropia said, Use SendMessage. You can do it followed by WM_LBUTTON.
Code:
LRESULT WINAPI SendMessage(
_In_ HWND hWnd,
_In_ UINT Msg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
You'll have something like this then:
Code:
#include <Windows.h>
HWND window = FindWindow(0, L"Your Window Title");
SendMessage(window, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
SendMessage(window, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
EDIT; I'm sorry I thought you wanted to send a mouseclick.
Well, here this is how you send the "x" key:
Code:
HWND window = FindWindow(0, L"Your Window Title");
SendMessage(window, WM_CHAR, 'x', 0);
Also, if you want to send a keystroke with SendMessage you can do something like this:
Code:
void sendText(LPCWSTR windowName, char* szText)
{
if (strlen(szText) < 1) return;
for (int i = 0; i < strlen(szText); ++i)
{
HWND hwnd = FindWindow(0, windowName);
SendMessage(hwnd, WM_CHAR, szText[i], 0);
}
}
Code:
sendText(L"Your Window Name", "some text here");