控制IE的地址栏(50分)

T

TOTO

Unregistered / Unconfirmed
GUEST, unregistred user!
我想IE的地址栏写了一些字符串,然后发送了回车字符。希望IE能够自动转到我写的地址中
但是IE根本不理我。
请教高手怎么回事?
 
她不喜欢你,,所以不理泥 :)

ie的地址栏是edit + combobox 的结合(至少我看object是这样子的)
你的发送代码贴出来瞅瞅。
 
编写IE的KeyPress(回车)事件
 
Function GetURL(H:hwnd;lparam:longint):boolean;stdcall;
var
str,url:array [0..254] of char;
begin
getclassname(h,@str,255);
if strpas(@str)='ComboBoxEx32' then
begin
EditHandle := H;
SendMessage(h, WM_GETTEXT, 255, LongInt(@url));
SendMessage(h, WM_SETTEXT, 255, longint(pchar('http://www.sina.com.cn')));
postmessage(h, WM_CHAR, 10, 0);
postmessage(h, WM_CHAR, 13, 0);
postmessage(h, SC_CLOSE, 0, 0);
form1.ListBox1.Items.Add(strpas(@url));
end;
result:=true;
end;

function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall;
var
str:array [1..255] of char;
begin
getclassname(h,@str,255);
if ((strpas(@str)='CabinetWClass') or (strpas(@str)='IEFrame')) then
begin
IEHandle := H;
Enumchildwindows(h,@GetURL,0);
end;
result:=true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.Clear;
Enumwindows(@callbackproc,0);
end;
 
上面的代码就可以设置IE的地址了,你可以发送一个消息给IE地址栏的Handle,模拟Enter
键。WM_KeyDown就可以了!
 
问题解决了吗?
by the way,你为什么不通过WinExec()传参数'http://www.sina.com.cn'的方法直接
激活IE呢?
 
顶部