javascript - 当按钮从 Web 浏览器控件按下到 WPF 时生成事件
问题描述
我正在尝试制作一个在 WPF 中的 HTML(Web 浏览器)控件中按下按钮时生成事件(任何事件)的应用程序。到目前为止,我已经搜索并尝试了各种实现,但没有运气。我还附上了最近的尝试,我能够操纵 html 中的值,从 html 中读取,但在按下按钮时无法获得事件。
public void webBrowser_LoadCompleted()
{
HTMLDocument doc = (HTMLDocument)webBrowser.Document;
IHTMLElementCollection theElementCollection = doc.getElementsByTagName("input");
foreach (IHTMLElement curElement in theElementCollection)
{
string uiAuto = curElement.getAttribute("fname").ToString();
if (uiAuto == "")
{
curElement.setAttribute("value", "changed value!");
}
if (uiAuto == "...")
{
curElement.setAttribute("value", "...");
}
if (curElement.getAttribute("value") == "Login")
{
curElement.click();
}
}
}
html
<!DOCTYPE html>
<html>
<head>
<title> Testing HTML </title>
</head>
<body>
<h1>Hi there!</h1>
<button type="button">Click Me!</button>
<input type="text" value="login" id="fname" name="fname"><br>
<h2>Bye!</h2>
</body>
</html>
我是 WPF 的新手,今天完成了这项任务。只想在我的 C# 应用程序中引发一个事件,当在 html 中按下按钮以及一些属性时,例如,文本框中的数据。
我还尝试编写一个 javascript 并在 webBrowser 中使用 invokeScript() ,但结果也不是很好。
期待一些帮助,谢谢。
解决方案
推荐阅读
- php - 使用 array_search 输出 common int
- r - 如何重命名一列的值?
- python - python电子邮件脚本循环错误想知道每次迭代
- python - 协方差矩阵返回不同的值
- html - 在零宽度元素中居中文本
- rasa - 用实体列表填充槽 | 拉萨
- python - 为什么我不能在“return”语句中使用 exec()
- visual-studio-2019 - 无法从 Visual Studio 2019 16.6.2 调试 Blazor 托管的 webassembly 3.2.0
- laravel - 验证数组 - 获取当前迭代
- sql - 使用带有多个表和连接的 Group By 进行 SQL 计数