如何得到另外一个应用程序的某一个窗体中文本框的内容(200分)

W

wdq

Unregistered / Unconfirmed
GUEST, unregistred user!
我碰到一个问题,要在我的程序中读取另外一个应用程序<br>的某一个窗体中文本框的内容,前提条件时,知道另一个应<br>用程序的名称、窗体的名称、文本框的名称<br>我只知道似乎可以用 GetDlgItemText 获得,但其中的参数<br>不只如何写。<br>还请诸位高手帮忙。
 
问tqz,他肯定知道以前他的主页上就有这样的程序,不过现在去不了喽
 
int GetWindowText(<br>&nbsp; &nbsp; HWND hWnd, // handle of window or control with text<br>&nbsp; &nbsp; LPTSTR lpString, // address of buffer for text<br>&nbsp; &nbsp; int nMaxCount // maximum number of characters to copy<br>&nbsp; &nbsp;);<br>不用说了吧,传递一个这个文本框的handle,和buffer....<br>至于如何获得文本框的handle,<br>FindWindowEx(FindWindow('应用程序窗体的类名', nil),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '文本框的类名',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRUE);<br>详细请看FindWindowEx and FindWindow 的help<br><br>
 
getwindowtext是标准方法,用这个方法可以获得*号密码正文
 
keys 真厉害。
 
to 阿蒙<br>I am Keyes not keys
 
1.find window's handle;<br>2.send a message to the handle to select all text.<br>3.send a message to copy to 剪切板(sorry)<br>4.send a message to paste to your program.<br>5.send a message to select none.
 
好像可以向它发一个gettext的消息,具体我忘了。查查以前的问题,有人答过的!
 
想盗密码?hehe
 
结束啦.
 
我试了,但不行,我不知道如何写文本框的类名?<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>取到每一个的内容呢?
 
如果是对话框内的edit, 可以以下方法得到(前提是你知道有几个EDIT)<br>var<br>hdlg, hedit1,hedit2....: hwnd;<br>text: pchar;<br><br>begin<br>hdlg:=findwindow(pchar('#32770'), pchar('窗口名‘));<br>hedit1:=findwindowex(hdlg,0,pchar('edit'),nil);<br>hedit2:=findwindowex(hdlg,hedit1,pchar('edit'),nil);<br>hedit3:=findwindowex(hedlg,hedit2,pchar('edit'),nil);<br>......<br>getmem(text, 255);<br>sendmessage(hedit1,wm_gettext,255, interger(@text));<br>....<br><br>如果是普通window, 把第一句改了。<br>我用这个做了个自动登录的工具,对付哪些过一段时间就要你重新登录的垃圾程序。
 
多人接受答案了。
 
顶部