A
ax518598
Unregistered / Unconfirmed
GUEST, unregistred user!
其它程序不是我自己编写的。在网上查到一段类似代码,但因自己太菜,不会改写,请高手帮忙改写一段代码假设另一程序标题为"***管理系统",需要获取的Edit坐标为(80,40)-(160,60))<br>以下为网上找的感觉类似的代码:<br>porcedure 得到目标窗体的句炳;<br>var<br> hCurWindow,hwnds: HWnd;// 窗口句柄<br> WinText: array [0..255] of char;<br>begin<br> // 获取第一个窗口的句柄<br> hCurWindow := GetWindow(Handle, GW_HWNDFIRST);<br> while hCurWindow &lt;&gt; 0 do<br> begin<br> // 获取窗口的名称<br> if GetWindowText(hCurWindow, @WinText, 255)&gt;0 then<br> if strpas(@wintext))='目标窗体的标题' then<br> begin<br> hwnds:=hcurwindow;//储存句炳<br> 跳出循环; <br> end;<br> listbox1.items.Add(StrPas(@WinText));<br> // 获取下一个窗口的句柄<br> hCurWindow:=GetWindow(hCurWindow, GW_HWNDNEXT);<br> end;<br>end;<br><br>function GetButtonHandle(hwnds: hwnd; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd,buffer,256);<br> //目标窗口的目标控件<br> if StrPas(Buffer)='Button' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> if buffer1 = '确定' then<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False;//终止循环<br> end;<br> end;<br>end;<br><br>procedure TfrmMain.bbtnStartClick(Sender: TObject);<br>var<br> Handle: Integer;<br> tmpHandle: Integer;<br>begin<br> {取句柄}<br> Handle := FindWindow(nil,'对话模式');//就是窗口的Caption<br> if Handle&lt;&gt;0 then<br> begin<br> tmpHandle := Handle;<br> //在这里循环取到想要的句柄为止 (****此处不知如何改)<br> //取发送按钮的,FButtonHandle<br> EnumChildWindows(Handle,@GetButtonHandle,Integer(@Handle));<br> FButtonHandle := Handle;<br> end;<br>end;<br><br>procedure 控制按钮;<br>begin<br> SendMessage(FButtonHandle,WM_LBUTTONDOWN,0,0);<br> SendMessage(FButtonHandle,WM_LBUTTONUP,0,0);<br>end; <br> <br>