mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
确定的(100,100)是相对于当前鼠标位置的,因而采用这种
方法很不好控制到向要点击的位置.
SetCursorPos(X,Y)是相对于整个屏幕的,可用
SetCursorPos(Left+Image1.Left,Top+20+Image1.Top)来
确定鼠标位置其中top+20是留出窗口标题栏.
我的测试程序如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
SetCursorPos(Left+Image1.Left+10,Top+20+Image1.Top+10);
Mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
Mouse_event(mouseeventf_leftup,0,0,0,0);
end;
Image的OnClick事件被调用了.