|
You can use this method
yourElement.FireEvent("event name","Dummy Object");
|
|
|
|
|
Hi there,
HTMLDocument CurrentDoc=(HTMLDocument)axWebBrowser1.Document;
m_source=CurrentDoc.documentElement.innerHTML;
I try to use AxWebBrowser with HTMLDocument to get HTML file source code.
Everything looks great but I get some troubles when web site contains frames :/.
I look in the Internet back and forward and found KB196340 article "How to get the WebBrowser object model of an HTML frame". ( http://support.microsoft.com/default.aspx?scid=kb;en-us;196340 ). I suppose that this might resolve my problem but I don't know how to use it in C# :/
Thanks,
Sebastian
It's simple ..........or.....not?
Cheers for helpful people from CodeProject LOL :P
|
|
|
|
|
You could always just load the first page and get the src for the iframes and then simple just load the frames url directly.
|
|
|
|
|
Yep you can do something like that :
<br />
object vFrame;<br />
object loc;<br />
<br />
loc = "http://www.mywebsite.com";<br />
<br />
vFrame = (object)"nameofmyframe";<br />
<br />
this.axWebBrowser1.Navigate2(ref loc, ref null_obj, ref vFrame, ref null_obj, ref null_obj_str);<br />
|
|
|
|
|
I want to refer to the frame as an element to access an element inside it or to get the html without messing with the frames, because the site i want to use it uses somekind of javascript to re-make the page with all the frames if i try to access a single frames page.
Even if i could do that, it wouldnt allow me to have a top or a left menu, and i need them
Any workaround?
|
|
|
|
|
Hi!
I'd like to use mshtml to process URLs and dump the text contents of finished pages into files or make them usable to programs in some other way - and I'd like to do this from a Windows Service - that means without any UI or browser Window. Does anyone know whether MSHTML supports this kind of use? I'm afraid not, because, for example, the property used to fire the DocumentComplete event is not set if the browser in which mshtml is running is not set to visible = true.
Any help anyone can offer to a .net newbie would be greatly appreciated.
|
|
|
|
|
hi,
I also want to realize such function.
Do u find a solution for that?
Any advice?
thanks
Gary Li
|
|
|
|
|
Hey
it seems that on some machines the axWebBrowser1_DocumentComplete event is not working and I do not understand why.
on my computer it works great, the DEMO in this tutorial AND the program I wrote, but on other machines it completly ignores the DocumentComplete event, and I really don't know why it happens.
help please! thanks!
|
|
|
|
|
I'm having a similar problem, not only does the DocumentComplete event not fire, but if I try to hook through the ProgressUpdate event the document has the type System.__ComObject instead of mshtml.HTMLDocumentClass
My thought was there was a version problem with mshtml.dll, which caused the ComImport to fail when creating the HTMLDocumentClass, but I wasn't sure how to verify, or correct this.
|
|
|
|
|
hey, I fixed it.
my problem was in the references. all the files in the references are, of course, important files for the program, but of these files don't get into my release directory because these are references, that all you have to do is check which files are NOT part of the .net framework (which means they're component) and add them to the release but clicking on the file (inside vs.net) and than check the "copy local" value to true.
another thing that I noticed, is that vs.net is not using mshtml.dll but microsoft.mshtml.dll, which is a different file, and that why it did not work on other computers.
|
|
|
|
|
Hello Respected sir/madam,
I have used Axwebbrowser control and mshtml component.
I actually downloading data from web site through windows application
in c#.net.
Problem with this is that while downloading data some of the records
get downloaded and after this ,application get's hang means it does
not do anything.
Sir, Please give me argent solution on this problem.
I am awaiting for your solution.
Thanks and Regards.
Kishor
kishor
-- modified at 0:41 Tuesday 25th October, 2005
|
|
|
|
|
|
Hi again.
I do this by myself. :->
When I'm using VS2005, there is necessary install a package that come with VS2005 "C:\Archivos de programa\Archivos comunes\Merge Modules\vs_piaredist.exe" (i'm sorry the name of folders in spanish, but will be something like "C:\Program Files\Common files\Merge Modules\vs_piaredist.exe"), and "voir à" the application runs.
So, thank you all for the attencion.
Cacho.
|
|
|
|
|
I want to have my own context menu when I right-click on this control, instead of default context menu (IE). Could you help me?
And again, could you tell me how to change the text size on the webpage that your control has loaded?
Thank in advance!
Lehoanq
|
|
|
|
|
Manually (if physical access) or dynamically (if remote) add the following to the HEAD Section:
document.oncontextmenu = function ()
{
window.event.cancelBubble = true;
return false;
}
Microsoft has a great axWebBrowser Text Sizing example (Article ID : 304103)
http://support.microsoft.com/default.aspx?scid=kb;en-us;304103[^]
Hope this helps,
~Alexander Kent
|
|
|
|
|
Thank you so much!
Now I can change text size. I post my code here (C#) - hope it's useful for someone!
Remember :
- Only call this function when Webbrowser has completely loaded its page (e.g. enable zoom button)
- using System.Reflection;
case "btnZoomIn":
i = new object();
o = new object();
//get current size
axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref i, ref o);
if ((int)o > 0)
o = (int)o - 1;
else
o = 0;
// set new size
axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref o, ref i);
break;
case "btnZoomOut":
i = new object();
o = new object();
// current
axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref i, ref o);
if ((int)o < 4)
o = (int)o + 1;
else
o = 4;
//set new one
axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref o, ref i);
break;
-------------------
But I still can't find the way to add a context menu
Please let me know if you can ! Thanks so much !
Leho@nq
|
|
|
|
|
|
DocumentComplete and NavigateComplete2 may fired multiple times.
the trick here doesn't work for www.msn.com: http://support.microsoft.com/kb/q180366/
check ReadyState of the web control doesn't work for www.msn.com
so what is the correct way to determine that the webpage is completely loaded?
thanks
|
|
|
|
|
Try
if ( ( (int)axWebBrowser1.ReadyState >= 4) & ( ! axWebBrowser1.Busy ))
{
//...
}
~Alexander Kent
|
|
|
|
|
Hi,
I like this program! Thank you so much for your sharing!
And by the way, could you add more new function like "Change Text Size"?
Thank you again!
Good day!
|
|
|
|
|
Not sure if this is where I should post this...
There is a an Internet site that shows their inventory online. The inventory is constantly changing (as are the prices), and you can buy the items directly from this page by checking a box, and adding the item to your cart.
I'm looking for a script that automates this task for me. The script would need to constantly reload the page, evaluating prices each time it does. If an item is found below the price I set, I need the script to to put a check in the box, and then immediately add the item(s) to my cart.
It is crucial that the script is fast at both parsing the html, and then executing the reload or "add to cart" commands. I've heard it can easily be done with C# and mshtml. Any other language is also fine, as long as it is fast.
Let me know if you think you can handle this, and an estimate on the cost for your skills. Thanks!!!
|
|
|
|
|
how to do this using vb.net?
Bcoz i am using this coding in vb.Net.
I'm searching result in a web page i want to post data. If anyone provides good examples like this in vb.net will be great.
Its Very very very Urgent. Provide an Urgent help
|
|
|
|
|
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports mshtml
Namespace mshtml_automation_demo
Public Class MainForm
Inherits System.Windows.Forms.Form
Private axWebBrowser1 As AxSHDocVw.AxWebBrowser
Private Task As Integer = 1
Private components As System.ComponentModel.Container = Nothing
Public Sub New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(MainForm))
Me.axWebBrowser1 = New AxSHDocVw.AxWebBrowser
CType((Me.axWebBrowser1), System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
Me.axWebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
Me.axWebBrowser1.Enabled = True
Me.axWebBrowser1.Location = New System.Drawing.Point(0, 0)
Me.axWebBrowser1.OcxState = CType((resources.GetObject("axWebBrowser1.OcxState")), System.Windows.Forms.AxHost.State)
Me.axWebBrowser1.Size = New System.Drawing.Size(616, 382)
Me.axWebBrowser1.TabIndex = 0
AddHandler Me.axWebBrowser1.Enter, AddressOf Me.FrmMain_Load
AddHandler Me.axWebBrowser1.DocumentComplete, AddressOf Me.axWebBrowser1_DocumentComplete
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(616, 382)
Me.Controls.Add(Me.axWebBrowser1)
Me.Name = "MainForm"
Me.Text = "Microsoft WebBrowser Automation"
AddHandler Me.Load, AddressOf Me.FrmMain_Load
CType((Me.axWebBrowser1), System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Private Sub FrmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim loc As Object = "STARTING WEB ADDRESS GOES HERE"
Dim null_obj_str As Object = ""
Dim null_obj As System.Object = 0
Me.axWebBrowser1.Navigate2(loc, null_obj, null_obj, null_obj_str, null_obj_str)
End Sub
Private Sub axWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent)
Select Case Task
Case 1
Dim myDoc As HTMLDocument = New HTMLDocumentClass
myDoc = CType(axWebBrowser1.Document, HTMLDocument)
Dim login_username As HTMLInputElement = CType(myDoc.all.item("login_username", 0), HTMLInputElement)
login_username.value="blahblah"
'etc etc add additional code to do whatever
System.Math.Min(System.Threading.Interlocked.Increment(Task), Task - 1)
Case 2
'break
End Select
End Sub
End Class
End Namespace
|
|
|
|
|
|
Hi,
I have a windows app that uses a browser control, that invokes navigate2 to fetch a web page. I need to intercept this page, which I have successfully done by changing document.body.innerHTML in event documentComplete. When the page shows up in the browser control, and the user clicks on a link, I need to intercept the page that is fetched for that as well. How do I do this? I was hoping that event 'documentCompelte' would also get triggered when I click on links on the page returned, but not so. Do I need to get to links via body.links, and set the onclick event for each link on the page returned? any sample code for this that I could refer to?
Also, I read that a browser control is memory intensive? How can I measure this? How bad it is to have two browser controls in one windows app?
Thanks.
-Shefali
|
|
|
|