locked
how to add my own menu to IE context menu RRS feed

  • Question

  • Hi

     

    Any give me the idea how to add my own menu to IE context menu

     

    Whenever user right clicks on a link my menu should be display like [download using VS]

     

    using my own menu i have to pass url or parameters to my exe

    thanks

     

    Monday, April 2, 2007 8:25 PM

Answers

  • Unlike script running in the browser, a context menu extension is not locked into the Local Machine Zone. So, you can create any ActiveX objects that you require for your task. The WScript Host provides the easiest way to launch an application.

     

    <script type="text/javascript">
     var win = window.external.menuArguments;
     var arg = win.event.srcElement.href;
     var wsh = new ActiveXObject("WScript.Shell")
     wsh.run(arg);
     // var myExe = "C:\\Full\\Path\\To.exe "; /* plus space */
     // wsh.run(myExe + arg);
     </script>

     

    WScript.Shell.Run uses ShellExecute to launch the associated application. (The example above opens the default browser.)

    Tuesday, April 3, 2007 4:35 PM

All replies

  • Adding Entries to the Standard Context Menu

    http://msdn2.microsoft.com/en-us/library/aa753589.aspx

     

    The technique works great for script files that access content of the main page through the window.external object.

     

    Register your menu item as a new key under: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt

    Set the (Default) value to the full path of the script file, and set "Contexts" (DWORD) = 0x20.

     

    In your script file, the event object indicates the DOM element that was clicked.

     

    <script type="text/javascript">
     var win = window.external.menuArguments;
     alert(win.event.srcElement.href);
     </script>

    Tuesday, April 3, 2007 12:06 AM
  • its working fine with js file but

    how can i pass
    Arguments to my c# exe file

    thanks


    Tuesday, April 3, 2007 6:13 AM
  • Unlike script running in the browser, a context menu extension is not locked into the Local Machine Zone. So, you can create any ActiveX objects that you require for your task. The WScript Host provides the easiest way to launch an application.

     

    <script type="text/javascript">
     var win = window.external.menuArguments;
     var arg = win.event.srcElement.href;
     var wsh = new ActiveXObject("WScript.Shell")
     wsh.run(arg);
     // var myExe = "C:\\Full\\Path\\To.exe "; /* plus space */
     // wsh.run(myExe + arg);
     </script>

     

    WScript.Shell.Run uses ShellExecute to launch the associated application. (The example above opens the default browser.)

    Tuesday, April 3, 2007 4:35 PM
  •  

    thanks

    Tuesday, April 3, 2007 6:43 PM
  • Hi,

         I have same requirement,I already did creating menu for selected text on IE,it's working,Then how is pass the arguments to C# EXE,Can you give the detailed explanation.

    Advance in Thanks

     

    Bala Nagaraj

     

    Saturday, April 21, 2007 10:33 AM
  • IE Button script to open the current location in Firefox (for developers to test their site for cross browser compatibility)

     

    <script language="javascript">
    // Open this location in FireFox
    var sURL = window.external.menuArguments.location;
    var WshShell=new ActiveXObject("wscript.shell")
    WshShell.run("FireFox " + sURL)
    </script>

     

    Download from http://www.iecustomizer.com/?url=iebuttons/?txtProvider=127

     

    <script language="javascript">
    // Open this location in Netscape
    var sURL = window.external.menuArguments.location;
    var WshShell=new ActiveXObject("wscript.shell")
    WshShell.run("Netscape " + sURL)
    </script>

     

    Download from http://www.iecustomizer.com/?url=iebuttons/?txtProvider=128

     

     

     

     

    Sunday, April 22, 2007 6:32 AM