读取外部程序中的label(100分)

  • 主题发起人 主题发起人 有问题
  • 开始时间 开始时间

有问题

Unregistered / Unconfirmed
GUEST, unregistred user!
大家好:<br>&nbsp; &nbsp; 请问如何从一个程序读取到另外一个程序中控件的数据,例如,读取另外一个程序中label<br>中的caption,其他的edit什么的我知道怎么取
 
如果两个程序都是自己写的倒有办法,如果。。。。就不知道了。
 
前提是:不是自己写的外部程序
 
得到你所需的句柄,然后访问
 
兄弟,我也知道,就是不知道怎么能得到他的句柄
 
仅供参考<br>&nbsp;function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br>&nbsp; buffer: array[0..255] of Char;<br>&nbsp; buffer1: array[0..255] of Char;<br>begin<br>&nbsp; Result := True;<br><br>&nbsp; GetClassName(hwnd,buffer,256);<br><br>&nbsp; if StrPas(Buffer)='Button' then<br>&nbsp; begin<br>&nbsp; &nbsp; GetWindowText(hwnd,buffer1,100);<br>&nbsp; &nbsp; if buffer1 = '送讯息(&amp;S)' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; PInteger(lparam)^ := hwnd;<br>&nbsp; &nbsp; &nbsp; Result:=False;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br><br>function GetEditHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br>&nbsp; buffer: array[0..255] of Char;<br>&nbsp; buffer1: array[0..255] of Char;<br>begin<br>&nbsp; Result := True;<br><br>&nbsp; GetClassName(hwnd,buffer,256);<br><br>&nbsp; if StrPas(Buffer)='Edit' then<br>&nbsp; begin<br>&nbsp; &nbsp; GetWindowText(hwnd,buffer1,100);<br>&nbsp; &nbsp; PInteger(lparam)^ := hwnd;<br>&nbsp; &nbsp; Result:=False;<br>&nbsp; end;<br>end;<br>
 
非常感谢楼上的兄弟,可是对label不行呀
 
label 是没有句柄的,应该是没有办法的
 
有没有其他的方法呀
 
可参考很多翻译软件鼠标取词的技巧
 
我想得到的它控件并没有显示出来,要读它的一些属性,<br>或者谁能告所我怎么得到hint(外部程序的)
 
那EDOT怎么取?
 
winsight 监视不到 label<br>不知道 spy++ 能不能监视到.
 
改一下<br>function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br>&nbsp; buffer: array[0..255] of Char;<br>&nbsp; buffer1: array[0..255] of Char;<br>begin<br>&nbsp; Result := True;<br><br>&nbsp; GetClassName(hwnd,buffer,256);<br><br>&nbsp; if StrPas(Buffer)='TLabel' then<br>&nbsp; begin<br>&nbsp; GetWindowText(hwnd,buffer1,100);<br>&nbsp; ShowMessage(StrPas(Buffer1))<br>&nbsp; end;<br>&nbsp; <br>&nbsp; if StrPas(Buffer)='TEdit' then<br>&nbsp; begin<br>&nbsp; SendMessage(HWnd, WM_GETTEXT, 1024, Integer(@Buffer1));<br>&nbsp; ShowMessage(StrPas(Buffer1))<br>&nbsp; end;<br><br><br>&nbsp; Result:=False;<br>end;<br><br>procedure Form1.Button1Click(Sender: TObject);<br>var<br>&nbsp; HWnd: THandle;<br>begin<br>&nbsp; HWnd:=FindWindow(nil, 'ProjectNAME');<br>&nbsp; EnumChildWindows(HWnd, @GetButtonHandle, Integer(@HWnd));<br>end;<br>
 
spy++可以,呵呵,
 
后退
顶部