So I'm trying to generate a key with the SendInput method in C++. It works very well until it comes to the specific game I want to use it in. It does the job in the game's chat but not in the game itself. I am using AHK for the script I want currently, but I wish to change to a native language to get more control over it. Looked up how AHK does it and apparently it uses the same method as I do, so I'm a bit confused. Why does AHK's method works without any problem and mine doesn't? I have tried many many different methods, but I just can't make it work.
Here's the code:
Code: Select all
void sendKey(char c) {
INPUT key;
key.type = INPUT_KEYBOARD;
key.ki.wVk = 0;
key.ki.wScan = VkKeyScan(c);
key.ki.dwFlags = KEYEVENTF_UNICODE;
key.ki.time = 0;
key.ki.dwExtraInfo = 0;
SendInput(1, &key, sizeof(INPUT));
key.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
Sleep(100);
SendInput(1, &key, sizeof(INPUT));
}
And here's my AHK script code that I want to implement in C++ (just a part, no sense copying the whole code):
Code: Select all
...
while BMActive = 1
{
...
Send yx
...
}
...