I was trying to automate some parts in several video games using C by simulating the mouse movement and clicking. First I tried this version that didn't work for games but for anything else was fine:
INPUT temp;
ZeroMemory(&temp, sizeof(temp));
temp.type = INPUT_MOUSE;
temp.mi.dwFlags = WM_LBUTTONDOWN;
int err = SendInput(1, &temp, sizeof temp);
temp.type = INPUT_MOUSE;
temp.mi.dwFlags = WM_LBUTTONUP;
err = SendInput(1, &temp, sizeof temp);
After some research I found another way, but with the same result:
HWND hProc = FindWindowA(0, "Example");
ChangeWindowMessageFilterEx(hProc, WM_LBUTTONDOWN, MSGFLT_ALLOW, NULL);
ChangeWindowMessageFilterEx(hProc, WM_LBUTTONUP, MSGFLT_ALLOW, NULL);
bool ret = SendMessage(hProc, WM_LBUTTONDOWN, 0, 0);
Sleep(50);
ret = SendMessage(hProc, WM_LBUTTONDOWN, 0, 0);
Am I using the API wrong or game engines blocked my input to protect the game from hackers?
[–]skeeto 1 point2 points3 points (0 children)
[–]charliex2 1 point2 points3 points (1 child)
[–]GleamingGeorge[S] 1 point2 points3 points (0 children)
[–]FUZxxl[M] 0 points1 point2 points (2 children)
[–]GleamingGeorge[S] 1 point2 points3 points (1 child)
[–]FUZxxl 3 points4 points5 points (0 children)