IE custom right-click link to open the program

Source: Internet
Author: User

IE custom right-click link to open the program

Http://www.enet.com.cn/article/2007/0628/A20070628692910.shtml

[Introduction]
First of all, you must add data items in the menu displayed when you right-click the link. The method to add data items is as follows:

First of all, add data items in the menu displayed when you right-click the link. The method to add data items is as follows.
1.1 Start Menu --> Run --> use the Regedit command to open the registry. We recommend that you back up the Registry first.
1.2 locate the registration point to "HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ menuext", right-click the menuext node, and choose new --> item.
1.3 give the new item a name, which is the name displayed when you right-click the menu. If you want to set a shortcut, you can use (& + letters.
1.4 set an address for the default value of the new item, such as E: \ mytest \ testielink.html. when you click our menu in the IE menu, the file will be called to execute the script. we will introduce how to add a script to the file to execute our custom program.
1.5 Add a DWORD value for the custom item we added. right-click the blank position on the right. create --> DWORD (32-bit) value. change the name to contexts (if any, right-click and choose rename), double-click contexts, and enter 20 in the value data item in the pop-up dialog box. A contexts object can define when a menu appears. You can use the value or combination it defines. the value is defined as follows:
Default 0x1 image 0x2 Control 0x4 form field 0x8 select text 0x10 anchor (Link) 0x20
If you want to right-click an image or link to display our menu like thunder, you can enter 22 (picture + link). If the contexts object is not set, the menu we define will be displayed when right-clicking all the places.

The final results are as follows:

The second step is to write a script to be called and start the program we want to execute.
2.1 Open notepad or another text editor. Enter:
1 <SCRIPT type = "text/JavaScript">
2 var win = Window. External. menuarguments;
3 var Arg = win. event. srcelement. href;
4 var wsh = new activexobject ("wscript. Shell ");
5 var myexe = "\" E: \ my_app \ recielink.exe \ "; // there is a space before the last quotation mark, because we need to input parameters to the started application.
6 wsh. Run (myexe + Arg, 1, true); // here, 1 indicates that the opened form is in focus, and true indicates that the window is waiting for execution.
7 </SCRIPT> for more wscript Shell objects, see http://msdn2.microsoft.com/en-us/library/aew9yb99.aspx
For more information about the parameters of the wscript. Shell run function, see: http://msdn2.microsoft.com/en-us/library/d5fk67ky.aspx

2.2 Save the content we wrote to the address set in 1.4. For example, E: \ mytest \ testielink.html.
In this step, I took a lot of detours and wasted about an hour to solve the path problem. you should note that. double quotation marks are added before the application path. this legend is a path convention to solve the space and other problems contained in the path. I wanted to start FF in IE at the time, but because FF is placed in the default path, a path error is always prompted, but there is no problem in the path without spaces. finally, I learned that the path should be enclosed in quotation marks. if you encounter such a problem elsewhere, such as a space error in the path, you may wish to add quotation marks before and after the path.
So far, we have completed the work of the major departments. Now let's write a C # program to receive the link parameters we transferred.
3.1 open Vs and create a console project.
3.2 modify the main function as follows:
1 static void main (string [] ARGs)
2 {
3 if (ARGs. length> 0)
4 {
5 console. Write ("I recieved a link :");
6 console. writeline (ARGs [0]); // we can use the ARGs parameter in main to obtain the link we passed in and print it on the screen.
7}
8 else
9 {
10 console. writeline ("link lost .");
11}
12 console. Read ();
13}
3.3 program to copy to "E: \ my_app \" and name it recielink.exe.
Let's test our results.

Okay, are you successful?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.