Is it possible...

Is it possible to make your cursor move via c++?
Last edited on
Try googling next time please.
1
2
3
4
5
6
#include <Windows.h>
int main()
{
	SetCursorPos(0, 0); //First argument is X, Second Argument is Y
	return 0;
}
you would also want to properly structure your post jason
little add to Pindrought's code,
1
2
3
4
5
6
7
8
9
10
11
#include <Windows.h>

int main(){

	for(int i=0, j=0; i<200; i++, j++){
		SetCursorPos(i, j);
		Sleep(10);
	}

	return 0;
}
hahaha, just noticed that you can make a virus with that!

randomly change cursor positions, sleep(1), run in infinite loop.
Last edited on
wow, thanks for telling me, I did not know that! I was just planning to make a program that simulates opening another program using the mouse.
now, is there a way to make it click?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

//Do it twice for double click. Leave the 4 zeros there all the time.

//I know exactly what you want lol, do this:

SetCursorPos(50, 100);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

//This code will move your cursor to 50,100 position on your screen, then double click.
Topic archived. No new replies allowed.