I really need help. I'm pretty new to c++. I want to send a simple keystroke to notepad (not really notepad, but I'm using it while I learn).
I might have forgotten something, I don't know. I have a feeling it's some retarded mistake...
#include <windows.h>
#define VK_A 0x9E
void SendKeys(HWND notepad);
void SendKeys(HWND notepad) {
PostMessage(notepad, WM_KEYDOWN, VK_A, 1);
}
int main() {
HWND notepad = FindWindow(NULL, L"Bajs.txt - Anteckningar");
SendKeys (notepad);
return 0;
}
I think I know what the problem is really, I need to get a keyboard handle on the window. But what do I use for that? I have tryed:
SetFocus(notepad);
From what I can understand SetFocus only works if notepad is in the same processthread as my program. Is there a way to get keyboard handle on a program that is not in the same thread?