如何从Windows应用程序填写html文本框 [英] how to fill in html textbox from windows application

查看:89
本文介绍了如何从Windows应用程序填写html文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想从Windows应用程序中执行以下操作:


1.打开浏览器并导航到URL 。

2.当我在浏览器窗口中找到正确的URL时,我想在我的Windows应用程序的页面上的html文本框中填写数据

。 br />
3.完成后我想按一个按钮。

4.最后我想导航到另一个URL。


好吧,看起来我完美地完成了第一个问题(我认为),但是在问题2上工作

就是在扼杀我。如何从我的Windows应用程序自动填写我的用户输入

到我的网络浏览器?


好​​的,这是我到目前为止所得到的:

SHDocVw.ShellWindows SWs = new SHDocVw.ShellWindows();

SHDocVw.InternetExplorer IExplorer = new

SHDocVw.InternetExplorer();


IExplorer.Visible = true;

IExplorer.Navigate( http ://MyURL.asp ,ref o,ref o,ref o,ref

o);


int counter = SWs.Count;


foreach(SHDocVw.InternetExplorer即在SW中)

{

if(ie.LocationURL.ToString()== < a rel =nofollowhref =http://MyURL/SubPage.asptarget =_ blank> http://MyURL/SubPage.asp )

{

IHTMLDocument2 document =(IHTMLDocument2)ie.Document;

MessageBox.Show(document.all.tags(" navn")。ToString());

//给我系统.__ ComObject ???


//到目前为止这么好了/>
//以下只是不起作用。也许我做错了吗?


HTMLTextElement navn =

(HTMLTextElement)document.all.tags(" navn");

navn.innerText =" HEJ";


}

}


任何人?


-

吉米

Hey

I would like to do the following from a windows application:

1. Open a browser and navigate to a URL.
2. When i am at the correct URL in my browser window, i want to fill in data
in the html textboxes on that page from my windows application.
3. When thats done i want to press a button.
4. last i want to navigate to another URL.

Well, it seems like i did the first issue perfectly (i think), but working
on issue number 2 is killing me. How can i fill in my user input
automatically to my web browser from my windows application?

Ok, heres what i got so far:
SHDocVw.ShellWindows SWs = new SHDocVw.ShellWindows();
SHDocVw.InternetExplorer IExplorer = new
SHDocVw.InternetExplorer();

IExplorer.Visible = true;
IExplorer.Navigate(http://MyURL.asp, ref o, ref o, ref o, ref
o);

int counter = SWs.Count;

foreach (SHDocVw.InternetExplorer ie in SWs)
{
if (ie.LocationURL.ToString() == http://MyURL/SubPage.asp)
{
IHTMLDocument2 document = (IHTMLDocument2)ie.Document;
MessageBox.Show(document.all.tags("navn").ToString ());
//Gives me System.__ComObject???

//So far so good
//The following is simply just not working. Maybe im doing it all wrong??

HTMLTextElement navn =
(HTMLTextElement)document.all.tags("navn");
navn.innerText = "HEJ";

}
}

Anyone?

--
Jimmy

推荐答案

嗨吉米,


首先,我想确认一下我对你的问题的理解。从

您的描述中,我了解您需要将您输入的所有内容从Windows窗体应用程序放入网页并导航到该页面。如果有任何误解,请随时告诉我。


根据我的经验,最好的做法是实现这个是用2

应用。一个是目前使用的winform应用程序,另一个是web应用程序,它将输入数据转换为html页面。


我们可以导航到网络应用程序的URL并将winform的值传递给

控件作为查询字符串。 Web应用程序获取查询字符串并在Web浏览器中显示带有值的

HTML页面。


HTH。


Kevin Yu

=======

此帖子已提供按原样没有保证,也没有赋予

权利。

Hi Jimmy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to put everything you input
from a Windows Form app into a web page and navigate to that page. If there
is any misunderstanding, please feel free to let me know.

Based on my experience, the best practice is to achieve this is to use 2
apps. One is winform app as currently used, the other is a web app which
converts the input data to an html page.

We can navigate to the web app''s URL and pass the values of the winform
controls as query string. The web app gets the query string and display the
HTML page with values in the web browser.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


" Kevin Yu [MSFT]" <,V - **** @ online.microsoft.com> skrev i en meddelelse

新闻:Jf ************** @ TK2MSFTNGXA01.phx.gbl ...
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> skrev i en meddelelse
news:Jf**************@TK2MSFTNGXA01.phx.gbl...
嗨吉米,

首先,我想确认一下我对你的问题的理解。从
您的描述中,我了解您需要将您输入的所有内容从Windows窗体应用程序放入网页并导航到该页面。如果
有任何误解,请随时告诉我。


我认为你得到了它,但是我将描述包括的步骤:


1. win应用程序应打开浏览器并导航到特定网站

loginURL(我自己的网页)。

2.在网页表单字段中输入用户名和密码的数据

3.按网页上的登录按钮

4.成功登录后,应导航到特定网页

根据我的经验,最佳做法是实现这是使用2
应用程序。一个是当前使用的winform应用程序,另一个是将输入数据转换为html页面的Web应用程序。


这需要我做一些网站开发。我实际上是想要b / b
避免这种情况,因为很多用户正在使用这些页面,我不想更改

任何内容。

我们可以导航到Web应用程序的URL并将winform
控件的值作为查询字符串传递。 Web应用程序获取查询字符串并在Web浏览器中显示带有值的HTML页面。
Hi Jimmy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to put everything you input
from a Windows Form app into a web page and navigate to that page. If
there
is any misunderstanding, please feel free to let me know.
I think you got it, but im gonna describe the steps included:

1. The win app should open a browser and navigate to a specific sites
loginURL (its my own web pages).
2. input the data for the username and password on the web pages form fields
3. press the login button on the web page
4. after a successfull login it should navigate to a specific web page
Based on my experience, the best practice is to achieve this is to use 2
apps. One is winform app as currently used, the other is a web app which
converts the input data to an html page.
That would require me to do some web development. I was actually trying to
avoid this, as many users are using these pages, and i wouldnt wanna change
anything on them.
We can navigate to the web app''s URL and pass the values of the winform
controls as query string. The web app gets the query string and display
the
HTML page with values in the web browser.




我可以看到您的观点,但是是不是可以从我的win应用程序直接将数据输入到网页上的字段


如果没有,我如何发布数据来自赢取应用程序到一个网站?


谢谢

吉米



I can see your point, but isnt it possible to input the data directly into
the fields on the web page from my win app.

If not, how du i post data from a win app to a web site?

thanks
Jimmy


" Jimbo" <ジ*** @ nospam.nospam> skrev i en meddelelse

新闻:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
"Jimbo" <ji***@nospam.nospam> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...


我想从Windows应用程序中执行以下操作:

1.打开浏览器并导航到URL。
2.当我在在我的浏览器窗口中输入正确的URL,我想从我的Windows应用程序中填写该页面上的html文本框中的数据。
3.完成后我想按一个按钮。
4最后我想导航到另一个网址。
Hey

I would like to do the following from a windows application:

1. Open a browser and navigate to a URL.
2. When i am at the correct URL in my browser window, i want to fill in
data in the html textboxes on that page from my windows application.
3. When thats done i want to press a button.
4. last i want to navigate to another URL.







好​​了第2点。


我的问题现在是第3点。好像我所做的一切都在起作用。你怎么能用你的win应用程序模拟按钮上的点击(输入类型=图像)。

吉米



Hey

Ok figured out point 2.

My probblem is now point 3. Seems like nothing that i do is working. How can
you simulate a click on a button (input type=image) from your win app.?
Jimmy


这篇关于如何从Windows应用程序填写html文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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