Solved

MouseClick at location

Posted on 1998-11-15
7
244 Views
Last Modified: 2010-04-01
Experts,
   Forgive me for asking a simple questions. After
moving cursor to a particular location (using SetCursorPos(x,y)), Is it possible to left mouse click (automation) at that position. I would like to write a program to click on "Get Quote" button every minute on an online brokers screen.

Thanks
0
Comment
Question by:fromind
7 Comments
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Well, you could use 'WindowFromPoint()' (and/or 'ChildWindowFromPoint()') to retieve the button's window handle and post a 'WM_LBUTTONDOWN'...
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
SendMessage(ThehandleOfTheButtonToBeClicked, WM_LBUTTONDOWN);
SendMessage(ThehandleOfTheButtonToBeClicked, WM_LBUTTONUP);

This would make a click  on the button...
0
 
LVL 7

Expert Comment

by:psdavis
Comment Utility
A cumulation of the above two answers gives you... (in MFC that is...)

CWnd* wndGetQuote = WindowFromPoint( CPoint( ptX, ptY ));
wndGetQuote->SendMessage( WM_LBUTTONDOWN );

There shouldn't be a reason for SetCursorPos.

Phillip

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Accepted Solution

by:
wyy_cq earned 200 total points
Comment Utility
1.the the window handle under the point
WindowFromPoint(...) or ChildWindowFromPoint()
2.send the mouse button down to the window,if you own the handle of the window you can send and message or command to it.
SendMessage(....)
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
wyy_cq - i think it is _NOT_ a good habit at all to simply post my comment as an answer!!!
0
 
LVL 7

Expert Comment

by:psdavis
Comment Utility
Especially when you do a WORSE job than the original!
0
 

Author Comment

by:fromind
Comment Utility
Thanks for the suggestions. It Worked.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now