W
williem
Unregistered / Unconfirmed
GUEST, unregistred user!
目的:了解如何在自己的程序中获得外部某个活动的窗口中指定的控件的值?如打开了拨号<br> 连接窗口中的电话号码?<br>我已做的:<br>//查询指定窗口的句柄<br>Function EnumWindowsProc(hWindow:hWnd;lParam:LongInt):Bool<br>{$IFDEF Win32} Stdcall;{$ELSE};Export;{$ENDIF}<br>var<br>lpBufferChar;<br>WindowCaptionFound:Bool;<br>ClassNameFound:Bool;<br>begin<br> GetMem(lpBuffer,255);<br> Result:=True;<br> WindowCaptionFound:=False;<br> ClassNameFound:=False;<br> try<br> if GetWindowText(hWindow,lpBuffer,255)>0 then<br> if Pos(PFindWindowStruct(lParam).Caption,StrPas(lpBuffer))>0 then<br> WindowCaptionFound:=True;<br> if PFindWindowStruct(lParam).ClassName='' then<br> ClassNameFound:=True<br> else<br> if GetClassName(hwindow,lpBuffer,255) >0 then<br> if Pos(PFindWindowStruct(lParam).ClassName,StrPas(lpBuffer))>0 then<br> ClassNameFound:=True;<br> if (WindowCaptionFound and ClassNameFound) then<br> begin<br> PFindWindowStruct(lParam).WindowHandle:=hWindow;<br> Result:=False;<br> end;<br> Finally<br> FreeMem(lpBuffer,SizeOf(lpBuffer^));<br> end;<br>end;<br>——————————————————————————————————————<br>//查询指定的窗口<br>Function FindAWindow(Caption:String;ClassName:String):THandle;<br>var<br>WinInfo:TFindWindowStruct;<br>begin<br> begin<br> WinInfo.Caption:=Caption;<br> WinInfo.ClassName:=ClassName;<br> WinInfo.WindowHandle :=0;<br> EnumWindows(@EnumWindowsProc,LongInt(@WinInfo));<br> FindAWindow:=WinInfo.WindowHandle;<br> end;<br>end;<br>——————————————————————————————————————<br>//得到指定窗口的各个控件的类和值,但不知道如何查找指定其中某个类的值<br>Function EnumChildProc(hWnd:integer;lParam:LongInt):Bool<br>{$IFDEF Win32} Stdcall;{$ELSE};Export;{$ENDIF}<br>var<br>Clsname,Caption:Array[0..60] of Char;<br>ff:string;<br>star:integer;<br>begin<br> GetClassName(hWnd,ClsName,60);<br> GetWindowText(hWnd,Caption,60);<br> Form1.Memo1.Lines.Add('类名'+ClsName+'值:'+Caption);<br> For star:=0 to Form1.ComboBox1.Items.Count do<br> begin<br> ff:=Form1.ComboBox1.Items[star];<br> if (ClsName='Static') and (Caption=ff) then<br> begin<br> Form1.Button1.Caption:='169';<br> Result:=True<br> end;<br> end;<br>end;<br>问题:我已经可以截获指定标题的外部程序的窗口了,但不知如何查询该窗口中指定的控件的值?<br> 也就是如何修改EnumChildProc已使他能实现这一功能??