function GetChromeURL(
const hwndChromeWindow: HWND):
string;
var
hwndChromeOmnibox: HWND;
function GetText(WindowHandle: HWND):
string;
var
TxtLength: integer;
Buf:
string;
begin
TxtLength := SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0) + 1;
SetLength(Buf, TxtLength);
SendMessage(WindowHandle, WM_GETTEXT, TxtLength, LongInt(@Buf[1]));
Result := Buf;
end;
begin
Result := '
';
hwndChromeOmnibox := FindWindowEx(hwndChromeWindow, 0, PChar('
Chrome_OmniboxView'),
nil);
//funzt auch nicht:
//hwndChromeOmnibox := FindWindowEx(hwndChromeWindow, 0, PChar('Chrome_AutocompleteEditView'), nil);
if hwndChromeOmnibox <> 0
then
Result := GetText(hwndChromeOmnibox);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
ChromeHWND: HWND;
Buffer:
array[0..255]
of Char;
s:
string;
begin
ChromeHWND := FindWindow('
Chrome_WidgetWin_0', Buffer);
if ChromeHWND <> 0
then
begin
s := GetChromeUrl(ChromeHWND);
MessageBox(
Handle, PChar(s), '
URL-Info', mb_Ok);
end
else
MessageBox(
Handle, '
Nix gefunden.', '
Fehler', mb_Ok
or mb_IconExclamation);
end;