Api-SendMessage取得窗口文本的用法?(50分)

  • 主题发起人 主题发起人 newstone
  • 开始时间 开始时间
N

newstone

Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi:<br>SendMessage(Handle, WM_GetText, 0, lParam)<br>中我想将取得的文本放入<br>&nbsp;Txt: Array[0..255] of char;<br>中,不知 lparam 如何使用?
 
来自:www 时间:2000-1-15 16:01:45 ID:175813 <br>var<br>&nbsp; aWindow: Hwnd;<br>&nbsp; L_ClassName, L_Content1: array[0..100] of char;<br>begin<br>&nbsp; try<br>&nbsp; &nbsp; aWindow :=findwindow(nil,'窗口名');<br>&nbsp; &nbsp; GetClassName(aWindow, L_ClassName, 100);<br>&nbsp; &nbsp; SendMessage(aWindow, WM_GETTEXT, 100, LongInt(@L_Content1));<br>&nbsp; &nbsp; Edit1.Text := StrPas(L_Content1);<br>&nbsp; except<br>&nbsp; end;<br>Edit1中就是你想要的东西。<br>&nbsp;<br>&nbsp;<br>
 
楼上的答案完全正确,小弟刚刚写了一个一摸一样的程序(屏幕取词,显示结果)
 
同意wjiachun<br>lparam在Delphi中被定义为长整型<br>所以要经过强制类型转换
 
var<br>&nbsp; str:pchar;<br>&nbsp; l:integer;<br>begin<br>&nbsp; l:=SendMessage(Handle,Wm_GetTextLength,0,0)+1;<br>&nbsp; GetMem(str,l); <br>&nbsp; SendMessage(Handle, WM_GetText, l, integer(str));<br>// str is the Text of the Window.<br>//It can get the passwords of the edit(Passchars:='*');<br>end;<br>
 
多人接受答案了。
 
后退
顶部