H
HowCan
Unregistered / Unconfirmed
GUEST, unregistred user!
请问,如何监控其他程序指定的文本框的数据,就是其他程序运行时,我自己的程序在后台始终在监控,因为有多个,所以有点麻烦,因为网上的只能监控到第一个文本框,比如以下代码:<br>function GetLocalTextInfoTest(var ReturnEditHandle:Integer):String;<br>var AHandle, BHandle: Integer;<br> R:Boolean;<br> mbuffer: array[0..255] of Char;<br> ss:string; <br> function GetComponentHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br> var s,sssss:string;<br> i,j:integer;<br> buffer: array[0..255] of Char; <br> begin<br> j:=0;i:=22;<br> if DebugState then sssss:=Uppercase('.SCROLLBAR.')//'TEDIT'<br> else sssss:='.EDIT.';<br> Result := True;<br> //得到目标窗口的控件<br> j:=GetClassName(hwnd, buffer, 256);<br> //找到目标窗口的TButton类目标控件<br> s:=StrPas(Buffer);<br> if Pos(sssss,uppercase(s))>0 then<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br> end; <br>begin<br> //取句柄<br> AHandle := FindWindow(nil, 'LabelPrint'); //就是窗口的Caption<br> //AHandle := FindWindow(nil, 其他系统'); //就是窗口的Caption<br> if AHandle<>0 then<br> begin<br> //在这里循环取到想要的句柄为止<br> R:=EnumChildWindows(AHandle, @GetComponentHandle, Integer(@BHandle));<br> if not R then begin<br> ReturnEditHandle:=BHandle;<br> SendMessage(BHandle,WM_GETTEXT,254,Integer(@mbuffer));<br> //GetWindowText(BHandle, mbuffer, 100);<br> ss:=StrPas(mBuffer);<br> Result:=ss;<br> end;<br> end;<br>end;