-
Mousekeys
Im doing a term project in grade 11 computer and information science. My project has a joystick that will controll the mouse. Unfortunatly, im fairly new to C++, and I don't how to move the mouse... I found this code and I think its what I need, but I dont know how to use it. Can anybody give me a hand?
-
Hi, welcome to the forums!
It sounds like you wish to use code to move the mouse cursor. You can do this with the SetCursorPos function or the mouse_event function. The page you linked to is part of the Windows CE documentation. If you are not using CE, you should use the normal Windows documentation.
Code:
#include <windows.h>
int main(void)
{
SetCursorPos(10, 20);
return 0;
}
-
Wow. That was way simpler than I thought it would be! Thanks very much! Now I need to do the whole joystick part...WooHoo... :( Any resources you might suggest for that?
BTW: how do you make it click?
-
>> BTW: how do you make it click? <<
You can use the mouse_event function to simulate a mouse click. A click consists of a button down event followed by a button up event.
Code:
#include <windows.h>
int main(void)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
return 0;
}