[Webinar] Streamline your web hosting managementRegister Today

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

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))));
0
cosminm
Asked:
cosminm
1 Solution
 
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
 
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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

Featured Post

Get your problem seen by more experts

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

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