S
stonegyy
Unregistered / Unconfirmed
GUEST, unregistred user!
我想操作一外部程序的文本输入框,有以下条件需要注意:<br> 1、外部程序是用pb写的。<br> 2、该外部程序上有许多文本输入框。<br> 3、该外部程序上有许多文本输入框是空的。<br> 4、只能操作其中一个文本输入框。<br> 我已经写了一个操作外部程序的程序,但是她不满足上述条件,请高手指教!!email:[?]
[?][?][?]xjue_root@163.com<br><br>附源码如下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Timer1: TTimer;<br> Edit1: TEdit;<br> Button1: TButton;<br> Button2: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>timer1.Enabled:=true;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>timer1.Enabled:=false;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>timer1.Enabled:=false;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br> H:HWND;<br> p:TPoint;<br>begin<br> GetcursorPos(P);<br> H:=WindowFromPoint(P);<br> //////////////////////////////////////<br> //此处判断该句柄是否是Tedit的句柄 and 是否是特定文本框的句柄<br> //////////////////////////////////////<br> SendMessage(H,WM_SETTEXT,0,Integer(edit1.Text));<br>end;<br><br>end.<br>
代码: