Mouse click

I wrote this line to make the mouse make a click on a program window at relative x,y. Is not working. What's wrong?

  PostMessage(ProgramHandle, WM_LBUTTONDOWN, MK_LBUTTON,
    Longint(PointToSmallPoint(Point(x, y))));
cosminmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

edeyCommented:
try changing the message you are posting:


WM_LBUTTONDBLCLK

fwKeys = wParam;        // key flags
xPos = LOWORD(lParam);  // horizontal position of cursor
yPos = HIWORD(lParam);  // vertical position of cursor
 

The WM_LBUTTONDBLCLK message is posted when the user double-clicks the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.


GL
Mike
0
men xinCEOCommented:
cosminm:

try this:

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

menxin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MadshiCommented:
Either use menxin's suggestion, or - if you don't like that the real mouse moves to that x,y position - change "programHandle" to "WindowFromPoint(point(x,y))".

Regards, Madshi.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

cosminmAuthor Commented:
Worked.
I have one more problem.
I want to change checked/unchecked a checkbox with a mouse positioned above it. Could you help me again?
0
men xinCEOCommented:
cosminm:

Thanx for your points!
And is this your means?

var pt:tpoint;
begin
.....
  pt:=Form1.ClienttoScreen(point(CheckBox1.Left,CheckBox1.Top));
  SetCursorPos(pt.x+4,pt.y+4);
.....
end;


menxin
Thanx again!  ;-)
0
cosminmAuthor Commented:
The most important thing is that I forgot to mention that the checkbox is in a window on the screen. Not in my program!
Thanx. I'm waiting a reply.
0
men xinCEOCommented:
Oh,it seems not easy...
0
cosminmAuthor Commented:
That's why I post it :)
0
men xinCEOCommented:
cosminm :

i have answered!  :-)

menxin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.