Solved

MouseClick at location

Posted on 1998-11-15
7
248 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
ID: 1177928
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
ID: 1177929
SendMessage(ThehandleOfTheButtonToBeClicked, WM_LBUTTONDOWN);
SendMessage(ThehandleOfTheButtonToBeClicked, WM_LBUTTONUP);

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

Expert Comment

by:psdavis
ID: 1177930
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Accepted Solution

by:
wyy_cq earned 200 total points
ID: 1177931
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
ID: 1177932
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
ID: 1177933
Especially when you do a WORSE job than the original!
0
 

Author Comment

by:fromind
ID: 1177934
Thanks for the suggestions. It Worked.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

837 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