不如通过鼠标来选取窗体的HANDLE:
如下,通过在PANEL1点击,拖动到你要得到HANDLE的窗体标题或者输入框上,松手
就得到HANDLE了。
procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var p:tpoint;
text:array[1..255] of char;
begin
if button=mbleft then
begin
screen.Cursor:=oldcursor;
getcursorpos(p);
ahandle:=windowfrompoint(p);//得到句柄
sendmessage(ahandle,wm_gettext,100,LongInt(@text));
if text[1]='' then
windows.getwindowtext(ahandle,@text,255);
edit1.Text:=text;
if edit1.text='' then edit1.Text:='对不起,失败了';
end; end;
如下,通过在PANEL1点击,拖动到你要得到HANDLE的窗体标题或者输入框上,松手
就得到HANDLE了。
procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var p:tpoint;
text:array[1..255] of char;
begin
if button=mbleft then
begin
screen.Cursor:=oldcursor;
getcursorpos(p);
ahandle:=windowfrompoint(p);//得到句柄
sendmessage(ahandle,wm_gettext,100,LongInt(@text));
if text[1]='' then
windows.getwindowtext(ahandle,@text,255);
edit1.Text:=text;
if edit1.text='' then edit1.Text:='对不起,失败了';
end; end;
qq不同窗口标题也不同!或者直接指定类名,QQ窗体的类名是:
FindWindow('#32770',nil);小弟这几天正在研究这个东西,已经搞定。