참조 추가 Microsoft Internet Controls(SHDocVw)와 Microsoft.mshtml 를 하고
using System.Runtime.InteropServices;
using SHDocVw;
using mshtml;
한다.
그 후
InternetExplorer ex = new InternetExplorer();
ex.Visible = true;
Object obj = null;
ex.Navigate("http://cyworld.com", ref obj, ref obj, ref obj, ref obj);
위와 같이 익스플로러를 실행시키고 (싸이월드로)
굳이 익스플로러가 아니더라도.. WebBrowser를 사용하셔도 됩니다.
private void button3_Click(object sender, EventArgs e)
{
IHTMLDocument2 hd;
hd = (IHTMLDocument2)ex.Document;
IHTMLElementCollection hCollection = (IHTMLElementCollection)hd.all;
object obj = "input"; //input 태그 찾으려고
IHTMLElementCollection he = (IHTMLElementCollection)hCollection.tags(obj);
foreach (IHTMLElement helem in he)
{
if (helem.getAttribute("name", 0) != null)
{
if (helem.getAttribute("name", 0).ToString() == "email") //소스를 보고 name속성의 값을 적는다, 아이디 항목
{
helem.setAttribute("value", (Object)"아이디", 0); //value 속성에 아이디를 대입
}
if (helem.getAttribute("name", 0).ToString() == "passwd")
{
helem.setAttribute("value", (Object)"비밀번호", 0);
}
}
}
}
'Program > C#' 카테고리의 다른 글
FTP 접속/다운로드/업로드/삭제/디렉토리 관 (0) | 2010.03.19 |
---|---|
MessageBox의 버튼 텍스트 변경하기 (0) | 2010.03.19 |
C# 포커스 빼앗지 않는 폼 구현하기 (0) | 2010.03.19 |
C#에서 Win32 API 사용하기 (0) | 2010.03.19 |
C#기준, 닷넷에서 ini파일 입/출력 (0) | 2010.03.19 |