🔒 Locked
Basic mouse manipulation in c++ help
Advertisement
Original Post
hey guys... i need help with something. i'm building an app in visual c++ and i need to know how to make my app actually move the mouse curson from position to position and "make" it left click. i thought to do it with sending a message to the message loop, but i wanted to check with you guys as to how to do it, just to be sure. thanx.
You can move the mouse with the SetCursorPos function. I'm not sure about how you'd make it click. If this is for your own app, I can't see any harm in posting a message in the message loop. If it's for another, you might have some issues, but you can still give it a go.
What are you trying to do, specifically?
i have a program which has no automated controls.
this program changes various things in my comp, but i have to click in that program to make the changes.
so i want to make a program which automatically launches the other prog, clicks a few things in it, types a few things in it, and then closes that program at acertain time interval, like every 12 hours.
this program changes various things in my comp, but i have to click in that program to make the changes.
so i want to make a program which automatically launches the other prog, clicks a few things in it, types a few things in it, and then closes that program at acertain time interval, like every 12 hours.
Quote:ShellExecute is what you're after.
Original post by Pav
ok, thanx a lot guys :)
1 more little question. how do i star another program and set the focus to it from within c++?
like if i want to execute c:\something.exe from within my app, and make it be in focus so i can use the mouse conrol on it?
ok, i wrote a simple prog just to test the function (console app) :
#include "windows.h"
void main()
{
INPUT mouseInput;
mouseInput.type = INPUT_MOUSE;
mouseInput.mi.dx = 10;
mouseInput.mi.dy = 10;
SendInput(1, &mouseInput, sizeof(mouseInput));
}
it fails to compile and says : "error C2065: 'INPUT' : undeclared identifier"
but it does know what INPUT is. it gave me context menus when i defined the mouseInput. stuff...
what does this mean?
#include "windows.h"
void main()
{
INPUT mouseInput;
mouseInput.type = INPUT_MOUSE;
mouseInput.mi.dx = 10;
mouseInput.mi.dy = 10;
SendInput(1, &mouseInput, sizeof(mouseInput));
}
it fails to compile and says : "error C2065: 'INPUT' : undeclared identifier"
but it does know what INPUT is. it gave me context menus when i defined the mouseInput. stuff...
what does this mean?
If you want to click some buttons and enter text I would adivce you to simply use Spy++ it you have that availbile to get the ID's of the desiered controls and then simply send the messages directly. I did a hack like this to get rid of the silly password prompt from tortoise cvs, simply I did a program that ran in the background checking if the tortoisecvs password window was displayed and if it was it simply enterd my login information and hit enter.
Saved me loads of time with very little effort.
Good luck with your program.
Saved me loads of time with very little effort.
Good luck with your program.
Quote:
Original post by Pav
i have a program which has no automated controls.
this program changes various things in my comp, but i have to click in that program to make the changes.
Does it have any command line options?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement