如何构建能够查找Html页面节点并向其发送密钥的C#程序 [英] How Do I Build C# Program Which Finds Html Page Node And Send Keys To It

查看:96
本文介绍了如何构建能够查找Html页面节点并向其发送密钥的C#程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我需要在C#中构建一个程序,接下来要做的事情:

1.连接到正在运行的网页进程(例如chrome)

2.按元素ID查找html节点。

3.程序应该回复节点的网页更改(例如,如果网络中的标签被称为1然后转到2然后程序应该通过msgbox提醒......)。

4.将密钥(即{ENTER})发送到网页,发送到特定的节点ID。



任何相关的想法\文章?



我设法将密钥发送到记事本这样的程序但不是铬\任何其他的互联网资源管理器。

也,我确实尝试通过ID捕获节点但它没有接口。



感谢请注意,

Ron。

Hello,
I need to build a program in C# which does the next things:
1. connects to a running process of web page (in example chrome)
2. finds an html node by element id.
3. the program should reply to the webpage changes of node (for example if a label in a web is called 1 and turned to 2 then the program should alert by msgbox...).
4. send keys (i.e {ENTER}) to the webpage, to a specific node id.

Any ideas \ articles that are related?

I did manage to send keys to a program like notepad but not to chrome \ any oother internet explorer.
also, i did try to catch nodes by ID but it doesn't interfaced.

thanks in regard,
Ron.

推荐答案

没有什么比尝试模拟关键事件更糟糕了。这是可能的,但这意味着巨大的浪费时间和不可靠的结果取决于许多因素,非便携式。相反,您可能需要一些 Web抓取的技术: http://en.wikipedia.org/wiki/ Web_scraping [ ^ ]。



详情请见我过去的答案:

从网页获取特定数据 [ ^ ],

如何从其他站点获取数据 [ ^ ]。



-SA
There is nothing worse than trying to simulate key events. It is possible, but would mean huge waste of time with unreliable results depending on many factors, non-portable. Instead, you may need some techniques of Web scraping: http://en.wikipedia.org/wiki/Web_scraping[^].

For further detail, please see my past answers:
get specific data from web page[^],
How to get the data from another site[^].

—SA


如果要向Chrome发送击键,您需要访问Chrome_RenderWidgetHostHWND窗口的句柄。这允许您将击键传递给Chrome,但这就是它。



另一种选择是使用 open-webkit -sharp [ ^ ]



如果你坚持IE,你可以使用最完整的C#Webbrowser包装器控件 [ ^ ],如果记忆正确,我可以让你执行你需要的操作。



最好的问候

Espen Harlinn
If you want to send keystrokes to Chrome, you'll need to access the handle of the Chrome_RenderWidgetHostHWND window. This allow you to pass keystrokes to Chrome, but that's about it.

Another option would be to use open-webkit-sharp[^]

If you stick to IE, you can use The most complete C# Webbrowser wrapper control[^] which, if memory serves me right, allows you to perform the operations you require.

Best regards
Espen Harlinn


这篇关于如何构建能够查找Html页面节点并向其发送密钥的C#程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆