德尔福铬 - 当网页按钮被用户点击启动在Delphi应用程序的命令 [英] Delphi Chromium - launch a command in Delphi application when button in web page is clicked by user
本文介绍了德尔福铬 - 当网页按钮被用户点击启动在Delphi应用程序的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Delphi应用程序铬成分。
I'm using Chromium component in a Delphi application.
我想以下行为:
当用户在一个网页上点击一个特定的按钮,德尔福应用程序(容器)必须执行命令(...启动外部可执行文件)。
When user clicks a specific button in a web page, the Delphi application (the 'container') must execute a command (launch an external executable with ...).
这可能吗?
推荐答案
的 更新:的
Update:
既然你居然问了DOM事件侦听click事件,请检查下面的例子听谷歌搜索按钮单击事件(ID为元素 gbqfba
)
Since you've actually asked for DOM event listener for click events, check the following example listening the Google search button click event (the element with 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;
这篇关于德尔福铬 - 当网页按钮被用户点击启动在Delphi应用程序的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文