积极答复者
c#webBrowser跨域点击按钮

问题
-
private void button2_Click(object sender, EventArgs e) { string aaa = "123456"; string bbb = "123456"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); //CorssDomainHelper.GetDocumentFromWindow接口
菜鸟新人一个,研究了一个星期了,还是没有结果,麻烦大神们帮帮忙,尽量写详细点,求带界面代码
<p class="miniLogin_btn cfl"> <input type="submit" class="no_bg" value="立即登录"> <input type="submit" class="no_bg" value="立即登录">
答案
-
您好!谢谢你对我的指导,帮我顺利解决了这个问题,还学到不少的东西,谢谢您!
刚刚我测试了一下,发现了两个小失误,我的版本是vs2005;所以this.Invoke(new MethodInvoker(() =>{}));
改为this.Invoke(new MethodInvoker(delegate{}));
还有一个就是我之前的错多了break;导致按钮无法提交;下面是在VS2005平台上成功运行的代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Timers; using mshtml; namespace WindowsApplication42 { public partial class Form2 : Form { System.Timers.Timer _timer = new System.Timers.Timer(); public Form2() { InitializeComponent(); int _Interval = 100; _timer.Enabled = true; _timer.Interval = _Interval; _timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); } private void Timer_Elapsed(object sender, ElapsedEventArgs e) { string CurrTime = System.DateTime.Now.ToLongTimeString(); string s = "20:01:00"; if (CurrTime == s) { this.Invoke(new MethodInvoker(delegate //this.Invoke(new MethodInvoker(() => { string aaa = "123456"; string bbb = "123456"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection)aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } } } ) ); } } private void Form2_Load(object sender, EventArgs e) { webBrowser1.Navigate("http://p.www.xiaomi.com/zt/xm_account/loginfacade.html?third=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fwww.xiaomi.com%2526sign%253DMWM0ZDg1YWE3ZDc4NGJjNzU0MDM4MmRiNzY0ZWY0MDJlYTVkODBlZA%252C%252C%26sid%3Deshop&sid=eshop&callback=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fwww.xiaomi.com%2526sign%253DMWM0ZDg1YWE3ZDc4NGJjNzU0MDM4MmRiNzY0ZWY0MDJlYTVkODBlZA%252C%252C&sign=3C15pt35v9KK5SR8saFsKQ89uRo%253D&1382244002316"); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) { string aaa = "123456"; string bbb = "123456"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection) aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } } }} } }
- 已建议为答案 ThankfulHeartModerator 2013年10月21日 3:01
- 已标记为答案 ThankfulHeartModerator 2013年10月21日 3:25
全部回复
-
可以把你的项目上传到SkyDrive或者网盘上让我们下载看看嘛?
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
首先,谢谢你!我赶出来了。献丑一下,下面是我的代码
IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection) aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } }
-
最好上传整个项目进行分析,另外您是什么问题呢?
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
我想实现,设置规定时间执行登录事件,但是出错了,指定的转换无效。另外,本人比较菜鸟,
不懂得上传网盘,非常感谢你百忙之中解答我的问题,谢谢!
System.Timers.Timer _timer = new System.Timers.Timer(); public Form2() { InitializeComponent(); int _Interval = 1000; _timer.Enabled = true; _timer.Interval = _Interval; _timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); } private void Timer_Elapsed(object sender, ElapsedEventArgs e) { string CurrTime = System.DateTime.Now.ToLongTimeString(); string s = "15:47:00"; if (CurrTime == s) { string aaa = "179166873"; string bbb = "as13544975580"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection) aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } } //程序执行代码 } //todo something }
-
您好,那么您具体是什么问题呢?有什么异常吗?你预期结果是什么?实际结果又是什么?
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
我晕死,图片发不了
我的具体问题是,例如:在中午12:00:00实现自动输入账号密码,提交,登录一个网站。预期结果是获取系统当前时间(CurrTime)转换成字符串 ,跟我声明的一个字符串是(s=12:00:00)对比,如果两者相等,执行代码自动输入账号密码
,提交,登录一个网站;实际结果是执行到12:00:00的时候 IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2);
发生错误,错误类型是:用户代码未处理 invalidcastexception:指定的转换类型无效
排错提示:当从一个数字执行强制转换时,值必须是小于无限大的数字
2、确保源类型可以转换为目标类型,
-
>>我晕死,图片发不了
您可以在这里用英语注明需要账号通过审核后方可发送图片。
>>用户代码未处理 invalidcastexception:指定的转换类型无效
您可以参考http://social.msdn.microsoft.com/Forums/exchange/zh-CN/79c9c73d-44fe-427d-a987-ed96b51cea53/systeminvalidcastexception-去解决您的问题。
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
如果你问题没有解决,没有必要标记答案,可以进一步提问;)
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
另外你的网盘最好是公布一个让人直接可以下载文件的链接,不知道你的问题解决了没有?
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
您好,附加说明的链接简短说明:System.Timers.Timer是一个专门用于服务器的后台线程(基于Thread构建)。你用这个后台线程控制一个前台的控件会产生此错误。因此内部应该用前台线程调用。
由于问题尚未解决,我取消标记答案,您可以尝试此方法:
1)重新创造一个新的C#类,黏贴一下代码(从Form2中移除,不建议把无关的代码放入Form2窗体中,否则会导致设计器无法正常工作打开):
[ComImport(), ComVisible(true), Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] public interface IServiceProvider { [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] int QueryService(ref Guid guidService, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppvObject); } public enum OLECMDF { OLECMDF_DEFHIDEONCTXTMENU = 0x20, OLECMDF_ENABLED = 2, OLECMDF_INVISIBLE = 0x10, OLECMDF_LATCHED = 4, OLECMDF_NINCHED = 8, OLECMDF_SUPPORTED = 1 } public enum OLECMDID { OLECMDID_PAGESETUP = 8, OLECMDID_PRINT = 6, OLECMDID_PRINTPREVIEW = 7, OLECMDID_PROPERTIES = 10, OLECMDID_SAVEAS = 4 } public enum OLECMDEXECOPT { OLECMDEXECOPT_DODEFAULT, OLECMDEXECOPT_PROMPTUSER, OLECMDEXECOPT_DONTPROMPTUSER, OLECMDEXECOPT_SHOWHELP } [ComImport, Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"), TypeLibType(TypeLibTypeFlags.FOleAutomation | TypeLibTypeFlags.FDual | TypeLibTypeFlags.FHidden)] public interface IWebBrowser2 { [DispId(100)] void GoBack(); [DispId(0x65)] void GoForward(); [DispId(0x66)] void GoHome(); [DispId(0x67)] void GoSearch(); [DispId(0x68)] void Navigate([In] string Url, [In] ref object flags, [In] ref object targetFrameName, [In] ref object postData, [In] ref object headers); [DispId(-550)] void Refresh(); [DispId(0x69)] void Refresh2([In] ref object level); [DispId(0x6a)] void Stop(); [DispId(200)] object Application { [return: MarshalAs(UnmanagedType.IDispatch)] get; } [DispId(0xc9)] object Parent { [return: MarshalAs(UnmanagedType.IDispatch)] get; } [DispId(0xca)] object Container { [return: MarshalAs(UnmanagedType.IDispatch)] get; } [DispId(0xcb)] object Document { [return: MarshalAs(UnmanagedType.IDispatch)] get; } [DispId(0xcc)] bool TopLevelContainer { get; } [DispId(0xcd)] string Type { get; } [DispId(0xce)] int Left { get; set; } [DispId(0xcf)] int Top { get; set; } [DispId(0xd0)] int Width { get; set; } [DispId(0xd1)] int Height { get; set; } [DispId(210)] string LocationName { get; } [DispId(0xd3)] string LocationURL { get; } [DispId(0xd4)] bool Busy { get; } [DispId(300)] void Quit(); [DispId(0x12d)] void ClientToWindow(out int pcx, out int pcy); [DispId(0x12e)] void PutProperty([In] string property, [In] object vtValue); [DispId(0x12f)] object GetProperty([In] string property); [DispId(0)] string Name { get; } [DispId(-515)] int HWND { get; } [DispId(400)] string FullName { get; } [DispId(0x191)] string Path { get; } [DispId(0x192)] bool Visible { get; set; } [DispId(0x193)] bool StatusBar { get; set; } [DispId(0x194)] string StatusText { get; set; } [DispId(0x195)] int ToolBar { get; set; } [DispId(0x196)] bool MenuBar { get; set; } [DispId(0x197)] bool FullScreen { get; set; } [DispId(500)] void Navigate2([In] ref object URL, [In] ref object flags, [In] ref object targetFrameName, [In] ref object postData, [In] ref object headers); [DispId(0x1f5)] OLECMDF QueryStatusWB([In] OLECMDID cmdID); [DispId(0x1f6)] void ExecWB([In] OLECMDID cmdID, [In] OLECMDEXECOPT cmdexecopt, ref object pvaIn, IntPtr pvaOut); [DispId(0x1f7)] void ShowBrowserBar([In] ref object pvaClsid, [In] ref object pvarShow, [In] ref object pvarSize); [DispId(-525)] WebBrowserReadyState ReadyState { get; } [DispId(550)] bool Offline { get; set; } [DispId(0x227)] bool Silent { get; set; } [DispId(0x228)] bool RegisterAsBrowser { get; set; } [DispId(0x229)] bool RegisterAsDropTarget { get; set; } [DispId(0x22a)] bool TheaterMode { get; set; } [DispId(0x22b)] bool AddressBar { get; set; } [DispId(0x22c)] bool Resizable { get; set; } } class CorssDomainHelper { private static Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); private static Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"); // Utility for IE cross domain access // Returns null in case of failure. public static IHTMLDocument3 GetDocumentFromWindow(IHTMLWindow2 htmlWindow) { if (htmlWindow == null) { return null; } // First try the usual way to get the document. try { IHTMLDocument2 doc = htmlWindow.document; return (IHTMLDocument3)doc; } catch (COMException comEx) { // I think COMException won't be ever fired but just to be sure ... } catch (UnauthorizedAccessException) { } catch (Exception ex) { return null; } // At this point the error was E_ACCESSDENIED because the frame contains a document from another domain. // IE tries to prevent a cross frame scripting security issue. try { // Convert IHTMLWindow2 to IWebBrowser2 using IServiceProvider. IServiceProvider sp = (IServiceProvider)htmlWindow; // Use IServiceProvider.QueryService to get IWebBrowser2 object. Object brws = null; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out brws); // Get the document from IWebBrowser2. IWebBrowser2 browser = (IWebBrowser2)(brws); return (IHTMLDocument3)browser.Document; } catch (Exception ex) { Console.WriteLine(ex); } return null; } }
2)在Form2中引入这个类,然后代码如下:
using System; using System.Windows.Forms; using System.Timers; using mshtml; namespace WindowsApplication41 { public partial class Form2 : Form { System.Timers.Timer _timer = new System.Timers.Timer(); public Form2() { InitializeComponent(); int _Interval = 1000; _timer.Enabled = true; _timer.Interval = _Interval; _timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); } private void Timer_Elapsed(object sender, ElapsedEventArgs e) { string CurrTime = System.DateTime.Now.ToLongTimeString(); string s = "15:43:00"; if (CurrTime == s) { this.Invoke(new MethodInvoker(() => { string aaa = "179166873"; string bbb = "as13544975580"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection)aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); break; } } })); } } private void button1_Click(object sender, EventArgs e) { } private void Form2_Load(object sender, EventArgs e) { webBrowser1.Navigate("http://p.www.xiaomi.com/zt/xm_account/loginfacade.html?third=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fwww.xiaomi.com%2526sign%253DMWM0ZDg1YWE3ZDc4NGJjNzU0MDM4MmRiNzY0ZWY0MDJlYTVkODBlZA%252C%252C%26sid%3Deshop&sid=eshop&callback=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fwww.xiaomi.com%2526sign%253DMWM0ZDg1YWE3ZDc4NGJjNzU0MDM4MmRiNzY0ZWY0MDJlYTVkODBlZA%252C%252C&sign=3C15pt35v9KK5SR8saFsKQ89uRo%253D&1382244002316"); } private void button2_Click(object sender, EventArgs e) { this.button2.Enabled = false; } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) { string aaa = "179166873"; string bbb = "as13544975580"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection) aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } } } } } }
注意粗体部分:
1)您不要在Button的Click事件中写操作Html文档的东西,必须放入DocumentComplete中(必须加载完毕)。
2)您必须用this.Invoke方法(通过UI线程操作)WebBrowser。
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice.- 已标记为答案 xwj杂草 2013年10月20日 13:13
- 取消答案标记 ThankfulHeartModerator 2013年10月21日 3:25
-
您先取消标记的答案,试试我的补充回答再说,不急的。不解决没有必要标记答案的。
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
PS:http://social.microsoft.com/Forums/en-US/8ba9ef1b-8503-46c3-bd28-4b7fad19b891/hello-please-verify-my-account-thanks?forum=reportabug#8ba9ef1b-8503-46c3-bd28-4b7fad19b891
请不要在此处发帖,您直接发到这里就可以了(直接跟帖),微软客服会统一批量处理(一周一次的);)
删除以上的那个帖子,直接发到这里:
http://social.msdn.microsoft.com/Forums/en-US/2040f706-fd63-4929-bfb8-4c96b4666a75/verify-your-account-7?forum=reportabug
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
现在有人回复了,估计删不掉了。算了。
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice. -
您好!谢谢你对我的指导,帮我顺利解决了这个问题,还学到不少的东西,谢谢您!
刚刚我测试了一下,发现了两个小失误,我的版本是vs2005;所以this.Invoke(new MethodInvoker(() =>{}));
改为this.Invoke(new MethodInvoker(delegate{}));
还有一个就是我之前的错多了break;导致按钮无法提交;下面是在VS2005平台上成功运行的代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Timers; using mshtml; namespace WindowsApplication42 { public partial class Form2 : Form { System.Timers.Timer _timer = new System.Timers.Timer(); public Form2() { InitializeComponent(); int _Interval = 100; _timer.Enabled = true; _timer.Interval = _Interval; _timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); } private void Timer_Elapsed(object sender, ElapsedEventArgs e) { string CurrTime = System.DateTime.Now.ToLongTimeString(); string s = "20:01:00"; if (CurrTime == s) { this.Invoke(new MethodInvoker(delegate //this.Invoke(new MethodInvoker(() => { string aaa = "123456"; string bbb = "123456"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection)aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } } } ) ); } } private void Form2_Load(object sender, EventArgs e) { webBrowser1.Navigate("http://p.www.xiaomi.com/zt/xm_account/loginfacade.html?third=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fwww.xiaomi.com%2526sign%253DMWM0ZDg1YWE3ZDc4NGJjNzU0MDM4MmRiNzY0ZWY0MDJlYTVkODBlZA%252C%252C%26sid%3Deshop&sid=eshop&callback=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fwww.xiaomi.com%2526sign%253DMWM0ZDg1YWE3ZDc4NGJjNzU0MDM4MmRiNzY0ZWY0MDJlYTVkODBlZA%252C%252C&sign=3C15pt35v9KK5SR8saFsKQ89uRo%253D&1382244002316"); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) { string aaa = "123456"; string bbb = "123456"; IHTMLDocument3 aa = CorssDomainHelper.GetDocumentFromWindow(this.webBrowser1.Document.Window.Frames["miniLoginFrame"].DomWindow as IHTMLWindow2); aa.getElementById("miniLogin_username").setAttribute("value", aaa, 0); aa.getElementById("miniLogin_pwd").setAttribute("value", bbb, 0); IHTMLElementCollection input = (IHTMLElementCollection) aa.getElementsByTagName("input"); foreach (IHTMLElement ht in input) { if (ht.getAttribute("type", 0).Equals("submit") != null) { ht.click(); } } }} } }
- 已建议为答案 ThankfulHeartModerator 2013年10月21日 3:01
- 已标记为答案 ThankfulHeartModerator 2013年10月21日 3:25
-
我以为你的名字都是唯一的,所以加了break。还是标记你的为答案吧。
Click For donating:Free Rice For the poor
For spamming-sender issues, you can either report it at Microsoft Spamming Issue, or just find "Report Spam Here+Number" at Forum Issue;You can also find "Verify Your Account+Number" at "Forum Issue", where you can submit to be confirmed to paste links or images.
For more things to talk about? StackOverFlow is your choice.