This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void JumpFramePage() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://homepage3.nifty.com/abe-hiroshi/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
var doc = IE.Document as mshtml.IHTMLDocument2; | |
object x = 1; | |
var window = doc.frames.item(ref x) as mshtml.HTMLWindow2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ShowCurrentPageTitleAndURL() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://finance.yahoo.co.jp/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
Debug.WriteLine(IE.LocationName + " : " + IE.LocationURL); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ClickImage() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://finance.yahoo.co.jp/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
var doc = IE.Document as mshtml.IHTMLDocument3; | |
foreach (mshtml.HTMLImg img in doc.getElementsByTagName("img")) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void CheckCheckBox() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://law.e-gov.go.jp/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
var doc = IE.Document as mshtml.IHTMLDocument3; | |
//1つ目の方法 | |
foreach (mshtml.HTMLInputElement ele in doc.getElementsByName("H_YOMI_GUN")) //item(index: ) では指定できず…(謎 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SelectDropDownList() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://law.e-gov.go.jp/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
var doc = IE.Document as mshtml.IHTMLDocument3; | |
{//1つ目の方法 | |
var dropdown = doc.getElementsByName("Y_TYPE").item(index: 0) as mshtml.HTMLSelectElement; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void OpenLink() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://www.google.com/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
var doc = IE.Document as mshtml.IHTMLDocument3; | |
doc.getElementById("lst-ib").innerText = "ぐるぐる"; | |
IE.Wait(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ClickButton() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://www.google.com/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); | |
var doc = IE.Document as mshtml.IHTMLDocument3; | |
doc.getElementById("lst-ib").innerText = "ぐるぐる"; | |
IE.Wait(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void InputText() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
object URL = "http://www.google.com/"; | |
IE.Navigate2(ref URL); | |
IE.Wait(); //ページ内の要素を書き換えるためには、ページが表示されるまで待つ必要あり | |
var doc = IE.Document as mshtml.IHTMLDocument3; | |
doc.getElementById("lst-ib").innerText = "ぐるぐる"; //id:lst-ib 検索ボックス | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ページの読み込み完了まで待機するための拡張メソッド | |
public static class SHDovVwEx | |
{ | |
public static void Wait(this SHDocVw.InternetExplorer ie, int millisecond = 0) | |
{ | |
while (ie.Busy == true || ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) | |
{ | |
Thread.Sleep(100); | |
} | |
Thread.Sleep(millisecond); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void QuitIE() | |
{ | |
var IE = new SHDocVw.InternetExplorer(); | |
IE.Visible = true; | |
IE.Quit(); | |
} |