Adding to the Internet Explorer context menu

This is a discussion on Adding to the Internet Explorer context menu within the Windows Programming forums, part of the Platform Specific Boards category; I've read a lot of stuff about shell extensions but I still have no idea how to add things to ...

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Adding to the Internet Explorer context menu

    I've read a lot of stuff about shell extensions but I still have no idea how to add things to the Internet Explorer context menu. For example, when a link is right clicked, I would like the context menu to have the option of executing my program with the link in the command line.

    Any ideas on how to do this?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Cheers anony.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I haven't been able to find anything that will actually do what I want. There's info on how to execute a program, but not about how to pass the link. And what about retrieving the COM interface to the browser? There's nothing about that.

    Has anyone ever done something like this?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The link can probably be obtained from the script page using:
    Code:
    var oWindow = window.external.menuArguments;
    var oLink = oWindow.event.srcElement;
    var sHref = oLink.href;
    As for getting the browser interface, you may want to look at browser helper objects which run in the context of the browser.

    Alternatively, you can enumerate internet explorer instances and find the instance that matches the event from an external application.
    http://support.microsoft.com/default...b;en-us;176792
    http://msdn.microsoft.com/library/de...ellwindows.asp

  6. #6
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    How can I run my program from a script? The context menu scripts I've seen don't seem to run anything. Eg:
    Code:
    <HTML>
    <SCRIPT LANGUAGE="JavaScript" defer> 
    var parentwin = external.menuArguments;
    var doc = parentwin.document;
    
    var GRlink = window.external.menuArguments.event.srcElement;
    if (GRlink == "[object]") {
    var GRlink = window.external.menuArguments.event.srcElement.parentElement;
    }
    if (GRlink == "[object]") {
    var GRlink = window.external.menuArguments.event.srcElement.src;
    }
    if (GRlink == null) {
    var GRlink = window.external.menuArguments.location;
    }
    
    //var GRurl = GRlink + "-getrightbrowse";
    var GRurl = GRlink + "-getrightdownload";
    //var GRurl = GRlink;
    
    parentwin.location.href = GRurl;
    
    </SCRIPT>
    </HTML>
    That is the code to make a download go through Getright. However, I can't really see how they call getright.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    You can open a Shell.Application object and use it's (probably undocumented) method ShellExecute

    Code:
    <SCRIPT language="JScript">
    	try
    	{
    		var oShell = new ActiveXObject("Shell.Application");
    		var strLnk = window.external.menuArguments.event.srcElement;
    		oShell.ShellExecute("BennysApp.exe",strLnk);
    	}
    	catch(e)
    	{
    		alert("Error - " + e.description);
    	}
    </SCRIPT>
    Just run the app and pass the href as an argument

  8. #8
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Thanks I'll give it a shot.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  9. #9
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    I thought that there was a registry key for this? I remember finding it when I was manually removing some stupid adware once.. that was IE 5 though I think it's probably the same still.

  10. #10
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Yep there's a registry key. In the key you refer to a script somewhere on your computer, which can then execute a program.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Adding commands to common context menus
    By Orderbringer in forum Windows Programming
    Replies: 2
    Last Post: 04-19-2005, 06:18 PM
  3. Adding a bar to the Menu? (C++)
    By Queatrix in forum Windows Programming
    Replies: 4
    Last Post: 04-17-2005, 07:11 PM
  4. Adding a Menu to a Dialogbox?
    By TCM in forum Windows Programming
    Replies: 2
    Last Post: 08-24-2004, 02:12 PM
  5. Adding menu resource to the window... HELP!!!
    By DeSeis in forum Windows Programming
    Replies: 6
    Last Post: 05-14-2002, 01:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21