Feature
|
Description
|
Toolbar
|
You can add new buttons and associate a behavior with them
|
Menu
|
You can add new menu items with or without a related toolbar button
|
Context Menus
|
It’s possible to customize many of the available context menus
|
Related Applications
|
There’s the possibility to customize the list of the applications you can run from Internet Explorer (mail clients or HTML editors)
|
Searching
|
You can customize the search assistant
|
Object Model
|
You can attach your own object model to the browser’s DOM
|
Behavior of HTML Tags
|
With behaviors you can customize the behavior of any HTML tag and define new tags as well
|
Interpreted Language
|
Due to the XML native support you can define your own language and have Internet Explorer support it as well
|
Figure 3 Creating a New Button
' AddButtonIE.vbs
' Adds a custom button to the Internet Explorer 5.0 toolbar
' -----------------------------------------------------------------------
rc = MsgBox("Would you like to add a new button to the toolbar?", vbYesNo)
if rc=vbNo Then WScript.Quit
' The registry path where you add your new entries.
' If your registry doesn't contain a Shell node, it'll be silently created
REG_HKLM_IE50_BASE = "HKLM\Software\Microsoft\Internet Explorer\Extensions"
' Adds a new key (needs a newly created GUID)
REG_HKLM_IE50_GUID = REG_HKLM_IE50_BASE & "\{10954C80-4F0F-11d3-B17C-00C0DFE39736}\"
' Creates the required values
Set shell = WScript.CreateObject("WScript.Shell")
shell.RegWrite REG_HKLM_IE50_GUID & "ButtonText", _
"Run Script", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "MenuText", _
"Run Script", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "MenuStatusBar", _
"Run Script", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Clsid", _
"{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Default Visible", _
"Yes", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Icon", _
"D:\Articles\Microsoft Internet Developer\Customize IE50\Source\icon1.ico", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "HotIcon", _
"D:\Articles\Microsoft Internet Developer\Customize IE50\Source\icon2.ico", _
"REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Exec", _
"D:\Articles\Microsoft Internet Developer\Customize IE50\Source\myprg.vbs", _
"REG_SZ"
Figure 5 Custom Button Registry Entries
Entry |
Description/b> |
ButtonText |
The text label of the button and the tooltip |
MenuText |
The text for the menu item that will appear under the Tools menu |
MenuStatusBar |
The text that appears on the status bar when the menu item is highlighted |
Icon |
The ICO file to show when the button is normal |
HotIcon |
The ICO file to show when the button is in its hot state |
Default Visible |
Yes or No according to whether the button must be visible by default |
Clsid |
A GUID identifying the type of the behavior associated with the button |
Figure 6 Getting the Running Instance
Private Declare Function GetForegroundWindow _
Lib "user32" () As Long
Private Declare Function GetWindowText _
Lib "user32" Alias "GetWindowTextA" ( _
ByVal HWND As Long, _
ByVal lpString As String, _
ByVal cch As Long _
) As Long
Private Declare Function GetWindowTextLength _
Lib "user32" Alias "GetWindowTextLengthA" ( _
ByVal HWND As Long _
) As Long
Public Property Get HWND() As Long
HWND = GetForegroundWindow()
End Property
Public Property Get Title() As String
Dim text As String
Dim nLen As Long
Dim hwndFocus As Long
hwndFocus = GetForegroundWindow()
nLen = GetWindowTextLength(hwndFocus) + 1
text = String(nLen, 0)
GetWindowText hwndFocus, text, nLen
Title = text
End Property
Public Property Get IEDocument() As Object
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Set IEDocument = Nothing
For Each IE In SWs
If IE.HWND = HWND Then
Set IEDocument = IE.Document
End If
Next
End Property
Public Property Get IEObject() As Object
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Set IEObject = Nothing
For Each IE In SWs
If IE.HWND = HWND Then
Set IEObject = IE
End If
Next
End Property
Figure 9 Context Values
Context Menu |
Hex Value |
Default |
0x1 |
Image |
0x2 |
ActiveX Control |
0x4 |
Table |
0x8 |
Text Selected |
0x10 |
Hyperlink |
0x20 |