Creating context menu options

ynotravid

Senior member
Jun 20, 2002
754
0
0
Hi all, I have been searching for awhile on this question. I came accross someone else who posted this same question on another forum but did not get an answer, I'm thinking Anandtech will do better.

I'd like to add a context menu item that appears in the context menu for selected text inside most applications. For instance, if you right-click on text in notepad, in the RUN combo-box, or even in the text box of the "Open URL" dialog in QuickTime, you will see that all of these "text receptacles" get their context menu from a common place (they all share the exact same commands in the same order, including "Right to left Reading order", "Show unicode control characters", "Insert Unicode control character").

So certainly this can be manipulated from somewhere, right? I would like to create an item for this menu that is enabled when activated on some highlighted text, then I would like to process that text in a script file (VBS, JS, whatever).

For instance, if the highlighted text is a valid URL, open it in a browser. If it's an email address, start an email. If it's a word, open it up in browser and send it to dictionary.com.

Can anyone tell me how to:
1) Add a menu item so it appears on the text context menu (not the context menus for files, directories, etc, just text)
2) send the highlighted text to a program as a parameter

I've seen a lot about creating custom context menu items in IE or other browsers, and also about creating custom context menus for certain applications, but I would like this to apply to text in almost any application (for instance, text in notepad, text in the RUN window combo box, whatever). I know there are applications that override with their own context menus and I don't hope to supplant them, just those that use the standard context menu. I know it's possible to customize the context menus for file and folders (like the custom WinZip menu item), so I'm hoping it's also possible to extend this one.

Thanks in advance!
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Windows usually exposes some COM interfaces for context menus for specific applications/environments (e.g. objects in the shell like files/folders, or web pages in IE). However I don't think there is such a facility for basic controls like the EDIT control, which is what you are looking to override. The common items you are seeing are likely all standard items. Personally I don't recall seeing a non-standard menu option in EDIT controls on any system I've used.

There are still a way to change the menu, however it is neither pretty nor recommended. In Windows you have the ability to "subclass" controls by intercepting messages, and you can extend this to other applications by installing a message "hook". Normally there is a WM_INITMENUPOPUP that allows you to modify the default menu, but EDIT doensn't do this, which means you need to implement the whole menu. There is some info here on subclassing the control inside the same application, and I think the same technique can be used with hooks to alter menus in other applications as well: http://msdn.microsoft.com/en-gb/magazine/cc301425.aspx but I recommend against this. It can mess up the UI because you need to hardcode the menus (which can be different between systems) and system-wide hooks must be carefully written to avoid system instability.

You also have to consider that different applications may use different controls to display text, so a solution for one control would not work universally.
 

Cogman

Lifer
Sep 19, 2000
10,278
126
106
In short, no, it is impossible to have one way that works with most applications. The way a context menu is implemented varies from app to app.
 

ynotravid

Senior member
Jun 20, 2002
754
0
0
dighn, Cogman, thanks for the input! I'm thinking a Windows shortcut key might be the way to go here. I'll post my results.

Thanks again!
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |