fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Threading;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. this.Load += new EventHandler(Form1_Load);
  19. this.Shown += new EventHandler(Form1_Shown);
  20. }
  21. HogeClass hogege = new HogeClass();
  22. void Form1_Load(object sender, EventArgs e)
  23. {
  24. this.hogege.WebBrowser.Dock = DockStyle.Fill;
  25. this.Controls.Add(hogege.WebBrowser);
  26. hogege.Url.Add("http://t...content-available-to-author-only...h.net/test/read.cgi/tech/1346940693/");
  27. hogege.Url.Add("http://e...content-available-to-author-only...h.net/test/read.cgi/poverty/1347865751/");
  28. }
  29. void Form1_Shown(object sender, EventArgs e)
  30. {
  31. hogege.NavigateStart();
  32. }
  33. }
  34. class HogeClass
  35. {
  36. public List<string> Url = new List<string>();
  37. public MyWebBrowser WebBrowser = new MyWebBrowser();
  38.  
  39. int i_status = 0;
  40. int count = 0;
  41. public void NavigateStart()
  42. {
  43. if (this.Url.Count != 0)
  44. {
  45. this.count = 0;
  46. this.WebBrowser.SetStatus = this.SetStatus1;
  47. this.WebBrowser.Navigate(this.Url[count]);
  48. }
  49. }
  50. private void SetStatus1(int SetStatus)
  51. {
  52. switch (i_status)
  53. {
  54. case 0:
  55. //文字入力
  56. this.WebBrowser.InputText("hogehoge");
  57. //ボタン押す処理
  58. //mwebb.ButtonClick();
  59. this.WebBrowser.Refresh(); //ボタン押下処理を書いてないのでダミー
  60. i_status++;
  61. break;
  62. case 1:
  63. i_status = 0;
  64. count++;
  65. if (this.Url.Count > count)
  66. this.WebBrowser.Navigate(this.Url[count]);
  67. break;
  68. }
  69. }
  70. }
  71. delegate void SetStatusCallback(int Status);
  72. class MyWebBrowser : WebBrowser
  73. {
  74. public SetStatusCallback SetStatus;
  75. private int _Count = 0;
  76. public MyWebBrowser()
  77. {
  78. this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(MyWebBrowser_DocumentCompleted);
  79. this.Navigating += new WebBrowserNavigatingEventHandler(MyWebBrowser_Navigating);
  80. }
  81.  
  82. void MyWebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
  83. {
  84. Interlocked.Increment(ref _Count);
  85. }
  86. void MyWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  87. {
  88. Interlocked.Decrement(ref _Count);
  89. if (this._Count == 0)
  90. {
  91. if (this.SetStatus != null)
  92. {
  93. this.SetStatus(0);
  94. }
  95. }
  96. }
  97. int hogehoge = 0;
  98. public void InputText(string s)
  99. {
  100. hogehoge = 1;
  101. //WebBrowserが表示してるwebページのテキストボックスへの文字入力
  102. }
  103. public void ButtonClick()
  104. {
  105. hogehoge = 0;
  106. //WebBrowserが表示してるwebページのボタンを押す処理
  107. }
  108. }
  109. }
  110.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty