Hello, I'm not entirely sure if this is the correct section to post this question so please move me if it is. Recently I have released a fishing bot in the 'World of Warcraft Bot" section, some users are saying the bot is working but not casting the fishing line, essentially its not sending the keystroke '1' for some and others it works. Maybe someone could take a look at my code and give me some suggestions as to why this is happening thanks! It's very confusing because its working perfectly for me and some users but others its just not sending the keystroke, my thought is maybe international keyboards could have some effect on this?
my function in which the key to press is sent to:
Code:
SendText("1", hwnd);
Code:
void SendText(string text, HWND hwnd)
{
for (int i = 0; i < text.length(); i++)
{
char c = toupper(text[i]);
static_cast<int>(c);
PressKey(c, 0, hwnd);
}
}
Code:
void PressKey(WORD key, int x, HWND hwnd)
{
int y = 0;
while (y <= x)
{
SetForegroundWindow(hwnd);
Sleep(50 + rand() % 100);
INPUT *keyClick;
keyClick = new INPUT;
keyClick->ki.wVk = key;
keyClick->type = INPUT_KEYBOARD;
keyClick->ki.dwFlags = 0;
keyClick->ki.time = 0;
keyClick->ki.wScan = 0;
keyClick->ki.dwExtraInfo = 0;
SendInput(1, keyClick, sizeof(INPUT));
Sleep(50);
keyClick->ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, keyClick, sizeof(INPUT));
y++;
}
}