C# - 控制弹出窗口(C# - Getting control of popup window)
我正在使用WebBrowser登录某些网站。 登录本身是可以的,但它打开了一个新窗口,我失去了对它的控制。 以下是代码段。
HtmlDocument htmlDocAceCounter = this.webBrowser1.Document; HtmlElement elementLoginID = htmlDocAceCounter.GetElementById("userid"); HtmlElement elementPassword = htmlDocAceCounter.GetElementById("userpasswd"); if ((elementLoginID != null) && (elementPassword != null)) { elementLoginID.SetAttribute("Value", "someid"); elementPassword.SetAttribute("Value", "somepw"); webBrowser1.Navigate("www.loginURL.com"); }
问题是它首先打开带有加密网址的新窗口,然后到达主网页。 所以我无法控制登录页面,以及我不知道如何到达那里。
无论如何还有解决这个问题的方法吗? 任何意见,将不胜感激。
编辑 :这并不完全重复。 这是我糟糕的解释。 首先使用loginURL.com打开新窗口,浏览加密的网址,然后打开登录页面。 我不知道它是如何检测到它的,但它只批准直接点击弹出窗口的有效访问。 我尝试了很多东西,但我不能在中间切割。 通过引用的示例,它不会到达加密的Web地址,只停留在loginURL.com。 我希望它能更好地解释。
Edit2 :来自
private void Web_V1_NewWindow(string URL, int Flags, string TargetFrameName, ref object PostData,string Headers, ref bool Processed) { Processed = true; //Stop event from being processed //Code to open in same window this.webBrowser1.Navigate(URL); //Code to open in new window instead of same window //Form1 Popup = new Form1(); //Popup.webBrowser1.Navigate(URL); //Popup.Show(); }
标题有Content-Type:application / x-www-form-urlencoded ,PostData有一些可以翻译成ascii字符的东西。 如何将它们翻译成正确的URL地址?
编辑3 :我用过
this.webBrowser1.Navigate(URL, TargetFrameName, (byte[])PostData, Headers);
代替
this.webBrowser1.Navigate(URL);
现在我得到COMException(0x80004005):错误HRESULT E_FAIL。 有人有什么主意吗?
I am using WebBrowser to login certain website. Login itself is okay, but it opens new window and I'm losing control of it. Below is code snippet.
HtmlDocument htmlDocAceCounter = this.webBrowser1.Document; HtmlElement elementLoginID = htmlDocAceCounter.GetElementById("userid"); HtmlElement elementPassword = htmlDocAceCounter.GetElementById("userpasswd"); if ((elementLoginID != null) && (elementPassword != null)) { elementLoginID.SetAttribute("Value", "someid"); elementPassword.SetAttribute("Value", "somepw"); webBrowser1.Navigate("www.loginURL.com"); }
Problem is that it opens new windows with encrypted web address first and reaches main webpage later. So I can't get the control of logged in page, as well as I don't know how to get there.
Is there anyway to workaround this issue? Any advice would be appreciated.
Edit: It's not duplicate exactly. It's my bad explanation. It first opens new window with loginURL.com, goes through encrypted web address, and then opens logged in page. I don't know how it detects it, but it only approves valid access from direct click popup. I tried many things, but I couldn't cut in the middle. With the referred example, it doesn't reach the encrypted web address and just stays at loginURL.com. I hope it explains better.
Edit2: From
private void Web_V1_NewWindow(string URL, int Flags, string TargetFrameName, ref object PostData,string Headers, ref bool Processed) { Processed = true; //Stop event from being processed //Code to open in same window this.webBrowser1.Navigate(URL); //Code to open in new window instead of same window //Form1 Popup = new Form1(); //Popup.webBrowser1.Navigate(URL); //Popup.Show(); }
Header has Content-Type: application/x-www-form-urlencoded and PostData has something that can be translated into ascii character. How do I translate them into right url address?
Edit3: I used
this.webBrowser1.Navigate(URL, TargetFrameName, (byte[])PostData, Headers);
instead of
this.webBrowser1.Navigate(URL);
and now I'm getting COMException (0x80004005): Error HRESULT E_FAIL. Does anyone have any idea?
原文:https://stackoverflow.com/questions/30912684
最满意答案
你可以把会议想象成一个房间。 任何在那个房间里的人都会看到对方。 无法为房间命名,但您可以在服务器上的某种存储空间中保留房间名称与房间的映射。
我不建议创建一个可供所有人重复使用的测试室,因为在测试设备时可能会有很多人看到对方。 我会为每个参与者创建一个单独的测试会话。
对于这个例子,你可以看看opentokdemo代码。 不幸的是,它是用JavaScript(Node.js)编写的,而不是Python,但您可以了解它是如何工作的。
这里是他们创建一个新的sessionId进行网络测试的地方。 他们为每个参与者创建一个新的sessionId供他们测试。
这里是逻辑是试图从持久存储获取房间名称的sessionId,如果没有一个,那么它会创建一个新的并存储它。
You can think of sessions like a room. Anyone that is in that room will see one another. There is no way to give a name to a room, but you can keep a mapping of room name to room in some kind of storage on your server.
I wouldn't recommend creating a test room that you reuse for everyone because you could end up with lots of people seeing one another when testing their devices. I would create a separate test session for each participant.
For an example of this you can look at the opentokdemo code. It's written in JavaScript (Node.js) unfortunately, not Python, but you can get an idea of how it works.
Here is where they create a new sessionId for doing a network test. They create a new sessionId for every participant for them to test in.
Here is where the logic is that tries to fetch the sessionId for a room name from persistent storage and if there is not one then it creates a new one and stores it.
相关问答
更多-
我的猜测是这个问题是由于字典rooms被定义的问题而发生的。 当你这样做 - rooms = { 'first_room': first_room.start(), 'north_room': north_room.start(), } rooms[room] 当你定义字典本身时,函数会被调用,而不是当你访问它的值(所以这两个函数被调用)时,你想存储函数对象(而不是调用它们)作为值,然后将它们称为 - rooms[room]() 。 示例 - def rooms(room): ...
-
实际上有一些方法。 天真的灵魂 粗略但简单地计算帧的大小并将其乘以帧速率(真实的,未指定的),然后再加上声速的kbps。 你应该得到非常准确的实际带宽图片。 有关帧速率计算,请参阅动态帧速率控制 OpenTok方法(合法的) 我敢打赌,一个好的用户体验解决方案不是要表明一切都不好,而是要调整流质量,只在完全失败的情况下表明错误(就像Skype一样)。 看这个: 从我们的2.7.0移动SDK版本开始,您可以使用每个确定的视频分辨率和每秒帧数(fps)启动发布者。 在使用API之前,您应该了解以下内容: 虽然高 ...
-
Tokbox相机过滤器API问题(Tokbox camera-filter API Issue)[2022-07-08]
它没有得到Tokbox的正式支持,因此他们(Tokbox)不会就此问题向您提供任何支持,但您可以从github上提交您的查询,从中获取此代码或API。 It is not officially supported by Tokbox so they(Tokbox) will not provide any support to you regarding this issue but you can submit your query on github from where you get this co ... -
好吧,似乎我可以回答我的问题,这部分是重复的 如何创建谷歌联系人? 事实证明,文档中的示例代码无效(感谢Google)PostCode应该是Postcode,即时消息地址也是不正确的。 删除它,它成功完成 Ok, it seems that i can answer my question, which is partly a duplicate of how to create google contact? It turns out that the sample code in the documen ...
-
组合档案的固定尺寸为VGA(640x480)。 如果您希望捕获完整的已发布分辨率,请考虑评估单个流归档。 有关详细信息,请参阅此链接。 https://support.tokbox.com/hc/en-us/community/posts/206241666-Archived-video-resolution-is-supposed-to-be-720x1280-but-reports-as-640x480 Composed archives have a fixed dimension of VGA (6 ...
-
你可以把会议想象成一个房间。 任何在那个房间里的人都会看到对方。 无法为房间命名,但您可以在服务器上的某种存储空间中保留房间名称与房间的映射。 我不建议创建一个可供所有人重复使用的测试室,因为在测试设备时可能会有很多人看到对方。 我会为每个参与者创建一个单独的测试会话。 对于这个例子,你可以看看opentokdemo代码。 不幸的是,它是用JavaScript(Node.js)编写的,而不是Python,但您可以了解它是如何工作的。 这里是他们创建一个新的sessionId进行网络测试的地方。 他们为每个参 ...
-
TokBox控制器/型号Ruby(TokBox Controller / Model Ruby)[2023-09-15]
您在前一篇文章中的博文中缺少before_filter :config_opentok,:except => [:index]行( https://railsfornovice.wordpress.com/2013/01/01/video-chatting-in-ruby- on-rails / ) You are missing the before_filter :config_opentok,:except => [:index] line from the blog post in your pre ... -
托盘 - 连接被拒绝(Tokbox - connection refused)[2021-01-22]
你有Android上网吗? Android设备是否连接到wifi的蜂窝网络? 似乎OpenTok很难与这些线路的服务器通信: errno: Connection refused ot_websvc_xml_request[*(ot_websvc_xml_req** ppwebsvc_xml_req)=0x58e71368] ERROR] jni/../src/ot_websvc_client.c:1291: errno: Connection refused ot_websvc_client_create ... -
API Rest Python(API Rest Python)[2023-09-08]
鉴于你的rbody结果,它将是 rbody[0]['name'] 但是,如果rbody是一个字符串,则需要先将其转换为Python对象 >>> import json >>> s = '''[{"id":8978437,"name":"LKJLKJ_OKJKJ_1900-09-12","parentId":8552450,"description":"","lastModified":"2017-02-06 14:45:40 +0100","type":0,"templateId":null,"templ ... -
对的,这是可能的。 您需要区分平台公开的API类型与您可以使用它做的事情。 虽然OpenTok API是围绕房间/会话的概念构建的 - 您可以轻松地使用该概念来创建呼叫。 有很多openTok开发人员都是这样做的。 Twilio确实提供了相同的功能 - 和许多其他功能一样(在本报告中可以找到部分列表 - https://bloggeek.me/webrtc-paas-report/ - 虽然报告是付费的,但列表可以在那个页面 Yes it is possible. You need to make the ...