# SendInput() scheint nichts zu tun



## Alph0r (23. Dez 2013)

```
void ClickButton(int x, int y){
	POINT  p;
	GetCursorPos(&p);
	INPUT inputArray[4];
	ZeroMemory(inputArray, sizeof inputArray);
	MOUSEINPUT move = {0};
	move.dx = x*(65536.0f/GetSystemMetrics(SM_CXSCREEN) - 1);//x being coord in pixels
	move.dy = y*(65536.0f/GetSystemMetrics(SM_CYSCREEN) - 1);//y being coord in pixels
	move.dwExtraInfo = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
	move.time = 0;
	INPUT moveInPut = {0};
	moveInPut.type = INPUT_MOUSE;
	moveInPut.mi = move;
	inputArray[0] = moveInPut;
	MOUSEINPUT down = {0};
	down.dx = x*(65536.0f/GetSystemMetrics(SM_CXSCREEN) - 1);//x being coord in pixels
	down.dy = y*(65536.0f/GetSystemMetrics(SM_CYSCREEN) - 1);//y being coord in pixels
	down.dwExtraInfo = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
	down.time = 0;
	INPUT downInPut = {0};
	downInPut.type = INPUT_MOUSE;
	downInPut.mi = down;
	inputArray[1] = downInPut;
	MOUSEINPUT up = {0};
	up.dwExtraInfo = MOUSEEVENTF_ABSOLUTE |MOUSEEVENTF_LEFTUP;
	up.dx = x*(65536.0f/GetSystemMetrics(SM_CXSCREEN) - 1);//x being coord in pixels
	up.dy = y*(65536.0f/GetSystemMetrics(SM_CYSCREEN) - 1);//y being coord in pixels
	INPUT upInPut = {0};
	upInPut.type = INPUT_MOUSE;
	upInPut.mi = up;
	inputArray[2] = upInPut;
	MOUSEINPUT back = {0};
	back.dx = p.x*(65536.0f/GetSystemMetrics(SM_CXSCREEN) - 1);//x being coord in pixels
	back.dy = p.y*(65536.0f/GetSystemMetrics(SM_CYSCREEN) - 1);//y being coord in pixels
	back.dwExtraInfo = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
	back.time = 0;
	INPUT backInPut = {0};
	backInPut.type = INPUT_MOUSE;
	backInPut.mi = down;
	inputArray[3] = backInPut;
	std::this_thread::sleep_for(std::chrono::milliseconds(1));
	int result = SendInput(4, inputArray, sizeof(INPUT));
	std::cout << result << std::endl;
		//SetCursorPos(x, y);
	POINT  p2;
	GetCursorPos(&p2);
	std::cout << "x: " << p2.x << " y: " << p2.y << std::endl;
	//SetCursorPos(x, y);
```

Woran kann der Fehler liegen? KeyStrokes funktionieren, nur die MouseClicks kommen nicht an. Ich versuche ein Editor Fenster anzuklicken, aber es bleibt einfach inaktiv.

Es gibt keinen Fehler, die Funktion returned 4, für die 4 INPUTs, die erfolgreich ausgeführt wurden.


----------

