本文整理自网络,侵删。
使用 API FindWindow 指定IE 窗口的Class类别,及窗口的标题文本, 将返回该窗口的句柄, 通过 API GetWindowRect 函数可以得到该窗口坐标位置注意,Delphi 也应该事先声明这些API 吧?
----------------获取指定程序位置
var
h:hwnd;
rt:TRect;
begin
h:=findwindow(nil,'计算器');
if h<>0 then
begin
GetWindowRect(h,rt);
showmessage(inttostr(rt.Left)+#13+inttostr(rt.top)); //左侧位置
end;
end;
----------------获取鼠标位置
procedure TForm1.FormClick(Sender: TObject);
var
P: TPoint;
begin
GetCursorPos(P);
Self.Caption := Format('X: %d, Y: %d',[P.X, P.Y]);
end;
-----------------移动鼠标-模拟单击操作
SetCursorPos(10,10);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
相关阅读 >>
Delphi fdconnection1 获取数据库总记录数
Delphi unigui中如何监听session的开始与结束
Delphi getwebbrowserhtml 获取网页源代码
Delphi tlistview(tlistbox+图标显示)
Delphi2010中使用pchar时e2010 incompatible types: 'char' and 'ansichar' 错误的处理
Delphi idhttp http.get 获取json数据
更多相关阅读请进入《Delphi》频道 >>