首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

如何得到IE浏览器的网址输入框的句柄

2013-01-23 
怎么得到IE浏览器的网址输入框的句柄?怎么得到IE浏览器的网址输入框的句柄?困扰我很久了浏览器[解决办法]

怎么得到IE浏览器的网址输入框的句柄?
怎么得到IE浏览器的网址输入框的句柄?困扰我很久了  浏览器
[解决办法]
用spy++抓
原理很简单,枚举窗口
[解决办法]


function GetIE6UrlHwnd: THandle;
const
  CtlNames: array[0..4] of string = (
    'WorkerW',
    'ReBarWindow32',
    'ComboBoxEx32',
    'ComboBox',
    'Edit'
  );
var
  i: integer;
begin
  Result := FindWindow('IEFrame', nil);
  if Result = 0 then exit;

  for i := 0 to Length(CtlNames) - 1 do
  begin
    Result := FindWindowEx(Result, 0, PChar(CtlNames[i]), nil);
    if Result = 0 then
      Break;
  end;
end;

function GetIE7UrlHwnd: THandle;
const
  CtlNames: array[0..5] of string = (
    'WorkerW',
    'ReBarWindow32',
    'Address Band Root',
    'ComboBoxEx32',
    'ComboBox',
    'Edit'
  );
var
  i: integer;
begin
  Result := FindWindow('IEFrame', nil);
  if Result = 0 then exit;

  for i := 0 to Length(CtlNames) - 1 do
  begin
    Result := FindWindowEx(Result, 0, PChar(CtlNames[i]), nil);
    if Result = 0 then
      Break;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := IntToHex(GetIE7UrlHwnd, 8);
end;

热点排行