rendered paste body#include <windows.h>
#include <stdio.h>
int main()
{
MSG msg;
HWND hwnd = FindWindow("Notepad",NULL);
hwnd = FindWindowEx(hwnd, NULL, "Edit", NULL); // Who uses more than one variable for this? Tut tut
if(hwnd)
{
ZeroMemory(&msg, sizeof(MSG)); // Thus we art lazy.
msg.hwnd = hwnd;
msg.message = WM_KEYDOWN;
msg.wParam = 65;
printf("DispatchMessage next...\nPress Enter...\n%i",msg.hwnd); // %i will show the hwnd btw
while(!GetAsyncKeyState(VK_RETURN)) Sleep(10);
DispatchMessage(&msg); //Fail to send "A" to Notepad...
printf("\nPostMessage next...\nPress Shift...\n");
while(!GetAsyncKeyState(VK_SHIFT)) Sleep(10);
PostMessage(hwnd,WM_CHAR,65,0); //Sends "A" to Notepad...
printf("\nDone!\nPress Escape...\n");
}
else { printf("Notepad not found!\n"); } // wtf
while(!GetAsyncKeyState(VK_ESCAPE)) Sleep(10);
return 0;
}