我用了Delphi应用程序铬成分。
我想以下行为:
当用户点击网页中的特定按钮,Delphi的应用程序(“容器”)必须执行命令(启动外部可执行文件...)。
可能吗 ?
我用了Delphi应用程序铬成分。
我想以下行为:
当用户点击网页中的特定按钮,Delphi的应用程序(“容器”)必须执行命令(启动外部可执行文件...)。
可能吗 ?
更新:
既然你居然问了DOM事件侦听click事件,请检查下面的例子听谷歌搜索按钮单击事件(ID为元素gbqfba
):
uses
ShellAPI, cefvcl, ceflib;
procedure TForm1.Button1Click(Sender: TObject);
begin
Chromium1.Load('www.google.com');
end;
procedure OnClickEvent(const AEvent: ICefDomEvent);
begin
ShellExecute(Form1.Handle, nil, 'notepad.exe', nil, nil, SW_SHOWNORMAL);
end;
procedure OnExploreDOM(const ADocument: ICefDomDocument);
var
DOMNode: ICefDomNode;
begin
DOMNode := ADocument.GetElementById('gbqfba');
if Assigned(DOMNode) then
DOMNode.AddEventListenerProc('click', True, OnClickEvent);
end;
procedure TForm1.Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser;
const frame: ICefFrame; httpStatusCode: Integer; out Result: Boolean);
begin
if Assigned(frame) then
begin
// here you should check the frame.Url to verify if you're on the right URL
// before you try to search for the element and attach the event if found
frame.VisitDomProc(OnExploreDOM);
end;
end;