You cannot set the cursor position or input of a window that required higher privileges than your program has..
If you want your program to be able to move the cursor over task manager, you require the same privileges as task manager: Administrator Privileges.
This is how it is done on Windows 8+.
I tried it with the following:
int main()
{
HWND window = FindWindow("TaskManagerWindow", "Task Manager");
if (window)
{
RECT rect = {0};
GetWindowRect(window, &rect);
SetForegroundWindow(window);
SetActiveWindow(window);
SetFocus(window);
Sleep(300);
SetCursorPos(rect.right - 200, rect.bottom - 200);
}
return 0;
}
Cursor only moves over task manager when ran as admin. It is the same for all context menus and windows in Windows 8+. Not just task manager.