Skip to content

Instantly share code, notes, and snippets.

@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:28
SHDocVwSample12
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;
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:26
SHDocVwSample11
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);
}
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:25
SHDocVwSample10
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"))
{
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:24
SHDocVwSample09
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: ) では指定できず…(謎
@dck-jp
dck-jp / test.cs
Last active August 29, 2015 14:22
SHDocVwSample08
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;
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:17
SHDocVwSample07
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();
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:15
SHDocVwSample06
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();
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:12
SHDocVwSample05
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 検索ボックス
}
@dck-jp
dck-jp / SHDocVwEx.cs
Created June 6, 2015 11:09
SHDocVwSample04
//ページの読み込み完了まで待機するための拡張メソッド
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);
@dck-jp
dck-jp / test.cs
Created June 6, 2015 11:04
SHDocVwSample03
public void QuitIE()
{
var IE = new SHDocVw.InternetExplorer();
IE.Visible = true;
IE.Quit();
}