Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

MouseClick at location

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
fromind
Asked:
fromind
1 Solution
 
jkrCommented:
Well, you could use 'WindowFromPoint()' (and/or 'ChildWindowFromPoint()') to retieve the button's window handle and post a 'WM_LBUTTONDOWN'...
0
 
viktornetCommented:
SendMessage(ThehandleOfTheButtonToBeClicked, WM_LBUTTONDOWN);
SendMessage(ThehandleOfTheButtonToBeClicked, WM_LBUTTONUP);

This would make a click  on the button...
0
 
psdavisCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wyy_cqCommented:
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
 
jkrCommented:
wyy_cq - i think it is _NOT_ a good habit at all to simply post my comment as an answer!!!
0
 
psdavisCommented:
Especially when you do a WORSE job than the original!
0
 
fromindAuthor Commented:
Thanks for the suggestions. It Worked.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now