General questions about Plugins
How to implement "Config" function of a Plugin
How to add new or override existing protocols
How to make a "Button" type plugin
How to make a "SideBar" type plugin
Extended DHTML support

General questions about Plugins:

1. COM Object

COM object must implement IMyIEClient interface. Please refer to IMyIE.h

2. Exe File:

Any win32 exe file could be used as plugin. MyIE2 will send different parameters under different circumstance.
General parameter:
a. "-h=handle" : handle is the Wnd handle of the MyIE2 main window, decimalist.

3. Script File:

Script File must be written in the following format:

Example:
<script language="Javascript">
alert(document.lastModified);
</script>

The 'language' could be any valid language that IE supports.


How to implement 'Config' function of a Plugin?

There is a 'Config' button in the 'MyIE2 Plugin' option page. MyIE2 will call the corresponding 'Config' function of a plugin, when user clicks the 'Config' button.

1. COM Object:

The COM's IMyIEClient::Config will be call with the parameter of the config dialog's hWnd handle.

2. Exe File:

The file will be called with a parameter of "-setup". For example, if the filename is "abc.exe", then MyIE2 will call "abc.exe -setup ..." .

3. Script File:

Not support currently...

How to add new or override existing protocols?

With MyIE2, the plugin could estanblish a new protocol, such as book://, or override an existing protocol, such as ftp:// .When the user inputs the protocol in the address bar or clicks the protocol on webpage, MyIE2 will call the plugin.

1. COM Object:

Not support currently...

2. Exe File:

The file will be called with the parameter "-u=url", in which the url is the address that the user wants to visit, such as book://www.mysite.com/abc.pdf, or ftp://www.google.com .

3. Srcipt File:

Not support currently...

How to make a "Button" type plugin?

MyIE2 supports "Button" type plugins, which will be placed on "Ext Button" toolbar. The plugin is called when user clicks on the corresponding button. The 'Button' plugin could be implemented using the following methods.

1.COM Object:

When user clicks on the button, MyIE2 will query the Com's IOleCommandTarget interface and ║═IObjectWithSite interfaceú¼passing the IWebBrowser2 pointer of the current page to its IObjectWithSite::SetSite functionú¼then call its IOleCommandTarget::Exec function. It's similar to IE's implementation of button. Please refer to MSDN for more information.

Sample Plugin.ini:

[General]
Name=ComButton
Author=bloodchen
Version=1.0
ModuleType=COM
FileName=ComButton.dll
CLSID={96E78121-9FF2-466D-B6CD-4038CAC1BB79}
Comments=Com type 'Button'
Type=M2Plugin_BUTTON
HotIcon=hot.ico
Icon=cold.ico


2.Script:

When the user clicks the button, MyIE2 will run the script on current web page.

Sample Plugin.ini:
[General]
Name=LastModified
Author=bloodchen
Version=1.0
ModuleType=SCRIPT
FileName=LastModified.htm
Comments=See last modified date of current page
Type=M2Plugin_BUTTON
HotIcon=hot.ico
Icon=cold.ico

3.Exe File:

When the user clicks the button, MyIE2 will call the file with the parameters of current address and handle of the main MyIE2 window. For example, the file is abc.exeú¼then MyIE2 will call abc.exe -h=23424 -u=http://www.yahoo.com, in which 23424 is the handle of the main MyIE2 window and http://www.yahoo.com is the URL of the current page.

Sample Plugin.ini:

[General]
Name=ExeButton
Author=BloodChen
Version=1.0
ModuleType=EXE
FileName=abc.exe
Comments=Exe type Button
Type=M2Plugin_BUTTON
Icon=p.ico

How to make a 'SideBar' type plugin

MyIE2 supports 'SideBar' pluginú¼This kind of plugin will appear on MYIE2's sidebar, implemented using a html file.

1.HTML:

When user clicks on the buttonú¼MyIE2 will load the html file into the side bar , which is assigned in the plugin.ini.

Example Plugin.ini:

[General]
Name=Calculator++ 1.2
Author=SiC
Version=1.2
ModuleType=SCRIPT
FileName=calculator.htm
Comments=Scientific programmable calculator.
Type=M2Plugin_Sidebar
HotIcon=cpp.ico
Icon=cpp.ico

2. COM

When user clicks on the buttonú¼MyIE2 will load the COM control into the side bar , which is assigned in the plugin.ini.

Example Plugin.ini:

[General]
Name=AXSidebar sample
Author=bloodchen
Version=1.0
ModuleType=COM
Comments=Simple activex side bar control
Type=M2Plugin_SideBar
FileName=AXSidebar.dll
CLSID={108C8E56-90AF-408B-873F-8AE3480BE090}
HotIcon=ax.ico
Icon=ax.ico

The COM plugin can be implemented in two ways:

1. A COM object similar to IE's browser band implementation. It must implement IObjectWithSite interface,
IDeskBand interface and optionally IInputObject interface. An example is the Net Snippet side bar plugin.

2. An activex control. Any valid activex control can be used, providing the correct CLSID. The activex control can optionally implement IObjectWithSite interface, from which MyIE2 will pass the active tab's IWebBrowser2 interface. If the activex control is not registered in user's system and the FileName is not empty, MyIE2 will try to register the file and load the control again. An example is the AXSidebar plugin (with source code).

Extended DHTML support

MYIE2 has extended the DHTML support by adding several new commands which could be called from script langauge. The HTML or scirpt writer could call the function through the 'window.external' object. The function could be called from the script in a HTML page or a scirpt plugin.

  1. addFavorite( url , title ) , addFavorite( url )

    This function will ask user to add the 'url' into favortes, using 'title' for the name of the url.

    Example1: external.addFavorite( "http://www.google.com" ); Demo
    Example2: external.addFavorite( "http://www.google.com","This is google"); Demo
  2. addProxy (name, address, speed, is_web_proxy)

    This function will call MYIE2's add proxy dialog to add the proxy named as 'name' at address 'address', giving the initial speed 'speed'. The is_web_proxy indicates whether the proxy is a web proxy or a normal proxy.

    Example: external.addProxy("My proxy","192.168.1.0:8080",1,0); Demo
  3. addFilter( address ) , addFilter( address, is_pop_filter )

    This function will call MYIE2's add filter dialog, setting the address to be filtered as 'address'. 'is_pop_filter' indicates whether the defalut filter type is 'pop filter'.

    Example1: external.addFilter("http://www.yahoo.com/ad*"); Demo
    Example1: external.addFilter("http://www.yahoo.com/img/*", 0); Demo
  4. readFile( plugin_name, file_name)

    This function can only be used in a script plugin, for the security reasons. The 'plugin_name' refers to the plugin name defined in plugin.ini and the 'file_name' indicates which file it wants to read. The function will reture the file contents. If the plugin is not enabled or the 'plugin_name' is wrong or not found, the function will fail and return null.

    Example: alert(external.readFile("Test plugin","plugin.ini")) ;
  5. writeFile( plugin_name, file_name, content )

    This function can only be used in a script plugin, for the security reasons. The 'plugin_name' refers to the plugin name defined in plugin.ini and the 'file_name' indicates the file name which will be write. The 'content' is the content that will be write to the file. If the plugin is not enabled or the 'plugin_name' is wrong or not found, the function will fail and return null.
    Please note: The file will be overwritten from the beginning.

    Example: external.writeFile("Test plugin","setting.ini","username=abc\npass=qwrxcv");

  6. tab_count : this property will return total number of tabs as a integer.

    Example: var total_tab = external.tab_count ; Demo

  7. activate_tab(index)

    This function will activate number 'index' tab of MyIE2.

    Example: external.activate_tab(1); Demo

  8. get_tab(index)

    This function will return a web page object of tab index.

    Example: alert(external.get_tab(0).document.URL); Demo

  9. cur_sel

    This function will return the number of current active tab as a integer.

    Example: var cur_tab = external.cur_sel; Demo

  10. close_tab(index)

    This function will close number 'index' tab of MyIE2.

    Example: external.close_tab(0); Demo
  11. m2_readIni(plugin_name,file_name,section_name,key,default_value)

    This function will read the key using the default_value in the ini file specified by file_name in the plugin folder.

    Example: path = external.m2_readIni("testplugin","settings.ini","general","save","0");
  12. m2_writeIni(plugin_name,file_name,section_name,key,value)

    This function will write assign the key with the value to the ini file specified by file_name.

    Example: external.m2_writeIni("testplugin","settings.ini","general","save","1");
  13. m2_search_text

    This property will return the text in MyIE2's search bar.

    Example: alert(external.m2_search_text)
  14. m2_run_cmd(id)

    This function will call a MyIE2's command with the ID. The id of every command could be found in the language file.

    Example: external.m2_run_cmd(32772); //It will open a blank page.
  15. m2_plugin_folder(plugin_name)

    This function will return the local path of the plugin.

    Example:external.m2_plugin_folder("ViewSource!");