Tuesday, October 24, 2006

IE context menu

Ok,create a IE context menu is not new any all.

Credits to old new things (http://blogs.msdn.com/oldnewthing/archive/2004/05/24/140283.aspx)
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Context_Name

Then we can do funky things in html page,you can use common scripting language like javascript, vbscript to manipulate functions.

< script language="Javascript">
var fac = prompt("Factor",100);
< /script>

As you see external is the object,with menuArguments method to do zooming.An alternative method is make a external object, port it as dll file or use your binary to output a html....Your design!

End? No yet, from a user's point of view, there might be some anonying malware injected into his/her IE, think about how to contrust a context menu?There you go, go to registry and delete the keys, also keep an eye on what lib it relies on(usually locates at HKCR\{id}), delete its lib as well. In fact, this is how some popluar anti-malware works (e.g:spybot), if you are designing similar software, it is worthwhile to dig into registry, the core of windows.

p.s: An interesting method by willij3 presents a shorter and neat hack

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Dictionary.com]
@="javascript: open('http://www.dictionary.com/cgi-bin/dict.pl?term=' + external.menuArguments.document.selection.createRange().text,\"dictionary\");"

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Google]
@="javascript: open('http://www.google.com/search?q=' + external.menuArguments.document.selection.createRange().text,\"google\");"

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Open In New Window]
@="javascript: open(external.menuArguments.document.selection.createRange().text);"

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Search Slashdot]
@="javascript: open('http://slashdot.org/search.pl?query=' + external.menuArguments.document.selection.createRange().text,\"/.\");"

No comments: