User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 428,467 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,155 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums

Mouse Click

Join Date: Mar 2008
Location: UK - Lymm
Posts: 439
Reputation: williamhemsworth is a jewel in the rough williamhemsworth is a jewel in the rough williamhemsworth is a jewel in the rough williamhemsworth is a jewel in the rough 
Rep Power: 4
Solved Threads: 43
williamhemsworth's Avatar
williamhemsworth williamhemsworth is offline Offline
Posting Pro in Training

Re: Mouse Click

  #9  
May 10th, 2008
It works with me

As long as you include the window header I think you can still use any of the functions there.
heres an example of what you can do with a console application.
#include <windows.h>
#include <cmath>

int main() {
	system("start c:\\windows\\system32\\mspaint.exe");
	HWND paint;

	do {
		paint = FindWindow("MSPaintApp", "Untitled - Paint");
		Sleep(10);
	} while (paint == NULL);

	Sleep(200);
	RECT r;
	GetWindowRect(paint, &r);
	RECT cr;
	GetClientRect(paint, &cr);

	int x = r.left + (cr.right / 2);
	int y = r.top + (cr.bottom / 2);

	SetCursorPos(x,y);

	POINT p;
	GetCursorPos(&p);
	paint = WindowFromPoint(p);

	GetWindowRect(paint, &r);
	GetClientRect(paint, &cr);

	x = r.left + (cr.right / 2);
	y = r.top + (cr.bottom / 2);

	SetCursorPos(x,y);

	int radius = 0;
	double angle = 0;

	int max = min(cr.right/2,cr.bottom/2);

	mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);

	for (; radius < max; radius++, angle += 0.1) {
		SetCursorPos(x+(cos(angle)*radius), y+(sin(angle)*radius));
		Sleep(20);
	}

	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

	return 0;
}
Last edited by williamhemsworth : May 10th, 2008 at 9:36 am.
Reply With Quote  
All times are GMT -4. The time now is 9:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC