Injecting/Sending Input directly to a program?

Currently i am trying to make a bot that automates a process for a game (it's a grindy mod so i have a bot go through the whole story and gain all the loots etc for me because im lazy BUT i have the issue currently that the game doesn't pick up all the SendInputs! Sometimes it does and others it doesn't and im not too sure why so what im trying to figure out is if i can have it send the input DIRECTLY to that game and nothing else?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
It's really really long as it's going through a long grindy process but i'll post the main thing of it
*/
void runbot() {
	Sleep(10000);
	INPUT ip;
	ip.type = INPUT_KEYBOARD;
	ip.ki.wScan = 0; // hardware scan code for key
	ip.ki.time = 0;
	ip.ki.dwExtraInfo = 0;
	// Set up a generic keyboard event.
	//START (Main Dialog Skip through with next :p)
	//First Next Button
	ip.ki.wVk = 0x4C; // virtual-key code for the "L" key
	ip.ki.dwFlags = 0; // 0 for key press
	SendInput(1, &ip, sizeof(INPUT));
	Sleep(1000);
	ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
	SendInput(1, &ip, sizeof(INPUT));
	Sleep(1000);
	SetCursorPos(x, y);
	Sleep(1000);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(500);
	//Second Next Button
	SetCursorPos(x2, y2);
	Sleep(1000);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

	//Actual Start
	SetCursorPos(x, y);
	Sleep(1000);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(1000);
	//KILL LEVEL 1
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(500);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(500);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(500);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(500);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	Sleep(500);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	//For Evil Button!
	Sleep(1000);
	ip.ki.wVk = 0x4C; // virtual-key code for the "L" key
	ip.ki.dwFlags = 0; // 0 for key press
	SendInput(1, &ip, sizeof(INPUT));
	Sleep(1000);
	SetCursorPos(x3, y3);
	Sleep(1000);
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
	//Stage 2 (Go Dirty Stoney)!
	Sleep(500);
	runbot2();
}


So through out the code sometimes it will pick up that i press L and other times it won't and i think it is just the game not getting the input cause ill go to notepad and the l will show up as if pressed but when i get to that part in game it won't and i've tried different things and right now im just out of ideas
Topic archived. No new replies allowed.