very please for help. On the net is very similar references to get a url or web source for active chrome tab. Most use "EnumWindows", they are all older. I am testing on W10, D7, but I feel that it calls "Chrome_AutocompleteEditView" does not work.
Can you help? I am sorry for my bad English
here is the code also notes what is not working
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, SHDocVw_EWB,
StdCtrls, Mshtml_Ewb, ComObj, ActiveX,ShlObj ;
type
TForm1 = class(TForm)
btn3: TButton;
Memo1: TMemo;
procedure btn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function GetActivePageUrlFromChrome(Handle: HWnd; Param: LParam): Bool; stdcall;
var
Form1: TForm1;
implementation
uses
Dialogs;
{$R *.dfm}
function GetActivePageUrlFromChrome(Handle: HWnd; Param: LParam): Bool; stdcall;
var
List: TStrings;
hWndChrome, hWndChromeChild: HWND;
Buffer : array[0..255] of Char;
begin
List := TStrings(Param);
SendMessage(Handle, WM_GETTEXT, Length(Buffer), integer(@Buffer[0]));
hWndChrome := FindWindow('Chrome_WidgetWin_1', Buffer);
if hWndChrome <> 0 then
begin
// inserted lines from testing
//PostMessage(hWndChrome, WM_CLOSE, 0, 0); - for testing handle correct
//note:
//When writing 'Chrome_WidgetWin_0', chrome is opened (ie. chrome handle is not ok)
//When writing 'Chrome_WidgetWin_1', chrome is closes (ie. chrome handle is ok)
//
hWndChromeChild := FindWindowEx(hWndChrome, 0, 'Chrome_AutocompleteEditView', nil);
if hWndChromeChild <> 0 then
begin
// ******************************************
// Here the program will never get - "Chrome_AutocompleteEditView" does not work?
// *******************************************
SendMessage(hWndChromeChild, WM_GETTEXT, Length(Buffer), integer(@Buffer));
List.Add(Buffer);
end;
end;
Result := True;
end;
procedure TForm1.btn3Click(Sender: TObject);
var
slChromeUrl: TStringList;
begin
slChromeUrl := TStringList.Create;
try
EnumWindows(@GetActivePageUrlFromChrome, LParam(slChromeUrl));
Memo1.Lines.AddStrings(slChromeUrl);
finally
FreeAndNil(slChromeUrl);
end;
end;
end.
