All pastes #616002 Raw Edit

Untitled

public text v1 · immutable
·published 2007-07-12 12:13 UTC
rendered paste body
#include <windows.h>
#include <stdio.h>

void main()
{
	HWND hwndParent;
	HWND hwndChild;
	MSG msg;
	POINT point = { 0, 0 };

	hwndParent = FindWindow("Notepad",NULL);
	hwndChild = FindWindowEx(hwndParent, NULL, "Edit", NULL);

	if(hwndChild)
	{
		msg.hwnd = hwndChild;
		msg.message = WM_CHAR;
		msg.wParam = 65;
		msg.lParam = 0;
		msg.time = 56261000; //Dunno what to put for this
		msg.pt = point; //Dunno what to put for this

		printf("DispatchMessage next...\n\n",msg.hwnd);
		system("pause");

		DispatchMessage(&msg); //Fail to send "A" to Notepad...

		printf("\nPostMessage next...\n\n");
		system("pause");

		PostMessage(hwndChild,WM_CHAR,65,0); //Sends "A" to Notepad...

		printf("\nDone!\n\n");
	}

	system("pause");
}