UnKnown Nick

I have a new context menu in internet explorer by modifying regsitry. Now I want an exe to open when user clicks on the menu item in internet explorer, but I am failing to achieve this. Can some one please help me. I have just placed exe path in the default value. Can some one help me >


Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

v04bvs

You have to write JavaScript code, to launch the exe file. After this, save this JavaScript code to some html file (in appropriate tags), and provide path to this file in the registry.




Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

UnKnown Nick

Thanks for your help. I have already done this and achieved it through javascript. I was just thinking if I can call an exe without using the script.Is it possible




Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

IECUSTOMIZER

Hi,

Excuse the butt-in, I don't think this is possible, unlike Command bar extensions, context menu extensions must be called by scripts.

Are you using the windows scripting object to launch your exe in your script This is shipped with Windows XP and higher. For earlier versions of windows you should give instructions in your setup program for users to install the required scripting engine from MS.

Its unusual to call an exe from the IE context menu as IE passes the external.menuArguments to the script. Here is a snippet from the Windows Live toolbar context menu search

<html>
<!--<object id=msnso align=top classid="clsid:320D9736-5661-4902-A90E-B55A9ADACBC3" width=1 height=1 border=0 vspace=0 VIEWASTEXT></object>-->
<script language="JavaScript" defer>
var useNewWindow = external.menuArguments.event.shiftKey;
var win = external.menuArguments;
var doc = win.document;
var sel = doc.selection;
var rng = sel.createRange();
var html = new String(rng.htmlText);
if(html == '')
{
if(win.event.srcElement.tagName == "A")
html = win.event.srcElement.innerText;
}
var str = html.replace(/<[^>]*>/g," ");
str = str.replace(/\s+/g, " ");
str = str.replace(/^\s*/,"");
str = str.replace(/\s*$/,"");
if (str.indexOf(" ") != -1)
str = '"' + str + '"';
var msnso = new ActiveXObject("WLT.WLTServer");
var url = msnso.GetSearchUrl(str);

if(useNewWindow)
win.open(url);
else
win.navigate(url);
</script>
</html>

Note how the WLT.WLTServer is called within the script and how external.menuArguments passes the context of the selection to the script.

Regards.






Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

UnKnown Nick

Rob Thanks for the help. I have already achieved this through javascript. I am a novice to Internet Explorer Extension and was just looking for maximum possible solutions around. Can you tell me what does "res:\\" means in registry. I have seen this in Context Menu under Internet Explorer in the registry.



Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

IECUSTOMIZER

Hi,

res:// is a protocol. It tells IE to load a resource from a local library file(dll or exe). Most toolbars store their context menu search script in the toolbar's com server.

Regards.






Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

UnKnown Nick

Ok I have got it. But can you please give me some example. How can I call my own application through this protocol

One thing more, about using script, see below line:

var wdApp = new ActiveXObject("Word.Application");

Can I specify my own application as the argument in ActiveXObject. If yes, any example and If no, what kind of applications I can I use there as argument.

Any good articles you suggest I should refer to understand the whole mechanics.

Thanks for your help.





Re: Internet Explorer Extension Development Context Menu Extension in Internet Explorer.

IECUSTOMIZER

Hi,

You need to add a resource type HTML to your exe or dll project (Visual Studio IDE), and import your context menu script file.

eg. Your script file is called say myscript.htm

Import this resource into your project as resource type html. Compile your project. say its called myexeordll.exe. Import any other resources (gifs, jpgs, hta,htc's) as html resources. You can call these resources from within your script.

You call this resource with res://{app folder}\myexeordll.exe/myscript.htm

Note the use of slashes and backslashes.

You can even pass parameters to your script.... res://{app folder}\myexeordll.exe/myscript.htm myparameter

Inside your script

var inputs = location.search.substr(1);

inputs will now contain myparameter

Next

var wdApp = new ActiveXObject("Word.Application");

I don't know if this works.... Compile your exe as an ActiveX exe... It should register the Class for your program as

{myprogram}.Application (if not you may have to include an Application class in your project, this should just be a wrapper class that just calls your main applicaton)

The compiler or regsvr32 should create a class entry in the registry for each public class in your project. eg. MyApplication.Class1, MyApplication.Class2 etc.

So you can now instansiate your ActiveX exe inside your contextmenu script and set properties or call methods based on the parameters you have passed to your script, as well as using the external.menuArguments object to access the browser window. Hey! remember (with all this control over the browser)... do no evil!

Regards.

Tip:. Find and download ResHacker.exe - use it to see how other toolbar addons work.