function GetActivePageUrlFromChrome(
Handle: HWnd; Param: LParam): Bool;
stdcall;
var
List: TStrings;
hWndChrome, hWndChromeChild: HWND;
Buffer :
array[0..255]
of Char;
begin
List := TStrings(Param);
//get the window caption
SendMessage(
Handle, WM_GETTEXT, Length(Buffer), integer(@Buffer[0]));
//look for the chrome window with "Buffer" caption
hWndChrome := FindWindow('
Chrome_WidgetWin_0', Buffer);
if hWndChrome <> 0
then
begin
hWndChromeChild := FindWindowEx(hWndChrome, 0, '
Chrome_AutocompleteEditView',
nil);
if hWndChromeChild <> 0
then
begin
SendMessage(hWndChromeChild, WM_GETTEXT, Length(Buffer), integer(@Buffer));
List.Add(Buffer);
end;
end;
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
slChromeUrl : TStringList;
begin
slChromeUrl := TStringList.Create;
try
EnumWindows(GetActivePageUrlFromChrome, LParam(slChromeUrl));
Memo1.Lines.AddStrings(slChromeUrl);
finally
FreeAndNil(slChromeUrl);
end;
end;