delphi2010 向另一个窗口发送鼠标点击事件
时间:2011-02-28 来源:阳光不远
ShowWindow(hCurrentWindow,SW_SHOWNORMAL);//恢复最小化的窗口,如果窗口最小化,无法成功发送鼠标事件
// 必要时还可以用到下面:
//ShowWindow(hCurrentWindow, SW_RESTORE);//恢复窗口
// ShowWindow(hCurrentWindow, SW_MINIMIZE);//最小化窗口
SetForegroundWindow(hCurrentWindow);//设置窗口为当前窗口
GetWindowRect(hCurrentWindow,r);//得到窗口的左上角坐标
getcursorpos(point); //获取鼠标原来的位置
setcursorpos(r.Left+120,r.Top+60); //设置鼠标在窗口的位置 ,即需要点的地方
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); //鼠标左键按下
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); //鼠标左键按下
setcursorpos(point.x,point.y); //恢复鼠标原来的位置
end;
hCurrentWindow := GetWindow(hCurrentWindow,GW_HWNDNEXT);
end;
end;
http://cy03wqh.blog.163.com/blog/static/3678030220108551731926/