|
|
|
date: Fri, 24 Jun 2005 11:25:03 -0700,
group: microsoft.public.inetsdk.programming.scripting.vbscript
back
Re: IWebBrowser2 Interface and Reset Default IE Settings
>
> Two quick questions:
> 1. Is there a way to tap into IWebBrowser2 Interface from VBScript? How
> would I go about doing this?
>
You can create an InternetExplorer.Application object, which
is virtually the same thing. It's just the COM version rather than
the C++ interface version. I don't know if the two are an exact
match but they're nearly the same. IE, the WebBrowser ActiveX
control, and the IWebBrowser interfaces are all versions of
the IE browser window.
> 2. Is there a way to reset all IE settings back to "factory settings"
using
> VBScript. I mean security settings, homepage, cookies, etc etc
>
I don't know of any "one-click" method to do that,
but the settings are all in the Registry. Unfortunately, the
IE settings are very complex and in many places, so you'd
have to do some research.
date: Sun, 26 Jun 2005 15:12:03 GMT
author: mayayana
Re: IWebBrowser2 Interface and Reset Default IE Settings
Greetings.
Regarding Question 2, I have looked into it and there are a number of
Registry Keys under
HKLM\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\ZoneMap\Domains
HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
HKLM\Software\Microsoft\Internet Settings\Main
and the same for HKCU. The problem is that in all it appears we have
perhaps a couple of hundre (200+) registry entry settings to reset back to
original. It would be nice if I could just invoke an IE object and say reach
the button under IE->Internet Options->Advanced->Reset Defaults or
IE->Internet Options->Programs->Reset Web Settings
It seems both of these will take care of many.
Regarding Questions # 1: How exactly would I do this?
I have done the following but dont gain or seem to know how to access
various events of methods for IE. This is what I have:
Set oIE=WScript.CreateObject("InternetExplorer.Application", "IE_")
With oIE
.navigate "about:blank"
.visible=1
.statusBar=1
.toolbar=1
.menubar=1
.resizable=0
End With
However, other than just a few properties such as oIE.navigate or oIE.HWND,
I dont know how to perhaps detect new Windows (could not get NewWindow event
to fire, or onNavigate). It seems the only event I get to work is onQuit.
Does anyone know how to access these. I see in MSDN that onNavigate or
NewWindow has parameters but dont know how to use these parameters.
Thanks
"mayayana" wrote:
>
> >
> > Two quick questions:
> > 1. Is there a way to tap into IWebBrowser2 Interface from VBScript? How
> > would I go about doing this?
> >
> You can create an InternetExplorer.Application object, which
> is virtually the same thing. It's just the COM version rather than
> the C++ interface version. I don't know if the two are an exact
> match but they're nearly the same. IE, the WebBrowser ActiveX
> control, and the IWebBrowser interfaces are all versions of
> the IE browser window.
>
> > 2. Is there a way to reset all IE settings back to "factory settings"
> using
> > VBScript. I mean security settings, homepage, cookies, etc etc
> >
> I don't know of any "one-click" method to do that,
> but the settings are all in the Registry. Unfortunately, the
> IE settings are very complex and in many places, so you'd
> have to do some research.
>
>
>
>
>
date: Sun, 26 Jun 2005 10:13:01 -0700
author: llamaflaca
Re: IWebBrowser2 Interface and Reset Default IE Settings
>
> Regarding Question 2, I have looked into it and there are a number of
> Registry Keys under
> HKLM\Software\Microsoft\Windows\CurrentVersion\Internet
> Settings\ZoneMap\Domains
> HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
> HKLM\Software\Microsoft\Internet Settings\Main
>
> and the same for HKCU. The problem is that in all it appears we have
> perhaps a couple of hundre (200+) registry entry settings to reset back to
> original. It would be nice if I could just invoke an IE object and say
reach
> the button under IE->Internet Options->Advanced->Reset Defaults or
> IE->Internet Options->Programs->Reset Web Settings
>
> It seems both of these will take care of many.
Assuming you can use something like SendKeys
to do that it might work, but I suspect that it isn't
a function that you can call directly, apart from pressing
the button. Also, you'll then need to do the same for
the 5 security zones and in IE6 you'll need to
deal with the Privacy tab settings.
( I don't know about:
Internet Options->Programs->Reset Web Settings
Maybe that's a solution. I don't know what it does,
but if it resets all settings then that would certainly be
a better option.)
>
>
> Regarding Questions # 1: How exactly would I do this?
> I have done the following but dont gain or seem to know how to access
> various events of methods for IE. This is what I have:
>
> Set oIE=WScript.CreateObject("InternetExplorer.Application", "IE_")
> With oIE
> .navigate "about:blank"
> .visible=1
> .statusBar=1
> .toolbar=1
> .menubar=1
> .resizable=0
> End With
>
> However, other than just a few properties such as oIE.navigate or
oIE.HWND,
> I dont know how to perhaps detect new Windows (could not get NewWindow
event
> to fire, or onNavigate). It seems the only event I get to work is onQuit.
> Does anyone know how to access these. I see in MSDN that onNavigate or
> NewWindow has parameters but dont know how to use these parameters.
>
You need to use something like:
While oIE.Visible = True
Wend
You can then get events with:
Sub IE_Eventname()
But it can only be event-driven from then on
because the script is busy "wending". One way
to make that more flexible is to add something like:
Do While IE.Visible = True
If BooVar = True then Exit Do
Loop
You can then use an event to set BooVar to
True if you want to release the script from its loop.
date: Sun, 26 Jun 2005 19:44:29 GMT
author: mayayana
Re: IWebBrowser2 Interface and Reset Default IE Settings
> Thanks. Very useful.
> Okay, Newbie questions then. I am looking at
>
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/inte
rnetexplorer.asp
>
> Looking at InternetExplorer Objects and there is no mention of
> Eventname.
>
> How do I call this??? I have something like this but no dice...
>
> Sub IE_Eventname
> WScript.Echo EventName.Name
> End Sub
>
I meant that as a sample of the syntax. It's set up
as declared event object + event name. So if
you use "IE_" in CreateObject as the object name
for events, then the subs will be like:
Sub IE_DownloadComplete()
Sub IE_NavigateComplete(sURL)
[ Note that the underscore is not an inherent part
of the declare. If you used "IEObject" in the
CreateObject function, instead of "IE_",
then it would be:
Sub IEObjectDownloadComplete()
]
If you need to find the parameters you can look at
SHDOCVW.DLL in an object browser. The events
for IE are as follows. (This should save you a half hour
or so clicking around the MSDN mess):
Event StatusTextChange(Text as String)
Info: Statusbar text changed.
Event ProgressChange(Progress as Long, ProgressMax as Long)
Info: Fired when download progress is updated.
Event CommandStateChange(Command as Long, Enable as Boolean)
Info: The enabled state of a command changed.
Event DownloadBegin
Info: Download of a page started.
Event DownloadComplete
Info: Download of page complete.
Event TitleChange(Text as String)
Info: Document title changed.
Event PropertyChange(szProperty as String)
Info: Fired when the PutProperty method has been called.
Event BeforeNavigate2(pDisp as Object, URL as Variant, Flags as Variant,
TargetFrameName as Variant, PostData as Variant, Headers as Variant, Cancel
as Boolean)
Info: Fired before navigate occurs in the given WebBrowser (window or
frameset element). The processing of this navigation may be modified.
Event NewWindow2(ppDisp as Object, Cancel as Boolean)
Info: A new, hidden, non-navigated WebBrowser window is needed.
Event NavigateComplete2(pDisp as Object, URL as Variant)
Info: Fired when the document being navigated to becomes visible and enters
the navigation stack.
Event DocumentComplete(pDisp as Object, URL as Variant)
Info: Fired when the document being navigated to reaches
ReadyState_Complete.
Event OnQuit
Info: Fired when application is quiting.
Event OnVisible(Visible as Boolean)
Info: Fired when the window should be shown/hidden
Event OnToolBar(ToolBar as Boolean)
Info: Fired when the toolbar should be shown/hidden
Event OnMenuBar(MenuBar as Boolean)
Info: Fired when the menubar should be shown/hidden
Event OnStatusBar(StatusBar as Boolean)
Info: Fired when the statusbar should be shown/hidden
Event OnFullScreen(FullScreen as Boolean)
Info: Fired when fullscreen mode should be on/off
Event OnTheaterMode(TheaterMode as Boolean)
Info: Fired when theater mode should be on/off
Event BeforeNavigate(URL as String, Flags as Long, TargetFrameName as
String, PostData as Variant, Headers as String, Cancel as Boolean)
Info: Fired when a new hyperlink is being navigated to.
Event NavigateComplete(URL as String)
Info: Fired when the document being navigated to becomes visible and enters
the navigation stack.
Event NewWindow(URL as String, Flags as Long, TargetFrameName as String,
PostData as Variant, Headers as String, Processed as Boolean)
Info: Fired when a new window should be created.
Event FrameBeforeNavigate(URL as String, Flags as Long, TargetFrameName as
String, PostData as Variant, Headers as String, Cancel as Boolean)
Info: Fired when a new hyperlink is being navigated to in a frame.
Event FrameNavigateComplete(URL as String)
Info: Fired when a new hyperlink is being navigated to in a frame.
Event FrameNewWindow(URL as String, Flags as Long, TargetFrameName as
String, PostData as Variant, Headers as String, Processed as Boolean)
Info: Fired when a new window should be created.
Event WindowMove
Info: Fired when window has been moved.
Event WindowResize
Info: Fired when window has been sized.
Event WindowActivate
Info: Fired when window has been activated.
date: Sun, 26 Jun 2005 22:36:18 GMT
author: mayayana
|
|