commedo's blogger

Friday, June 18, 2004

[HACKING] MSIE Custom Context Sensitive Menu

If you are amazed with Google toolbar which is one of its feature is googling by right clicking on selected text, you can make it by your self.

What I Need?
1. Registry Editor, commonly you just simply typing regedit on Start | Run
2. Text/HTML editor to create an HTML file

How?
1. Run regedit from Start | Run
2. Locate section: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt
3. Right click, select menu New | Key
4. Edit new string (New Key #1) with &Google Search for instance. This time, we will create context selective menu to do googling for selected words. Character & indicates shortcut, in this case 'G' as a shortcut.
5. Click &Google Search. Double click on entry (Default), and fill: d:\comm\google-search.html for instance. This indicates location of file which will be executed by if selecting menu "Google Search".
6. Create new Entry, right click on right panel after entry (Default): New -> Binary Value
7. Change new entry name to "contexts" (without double-quotes)
8. Double click on that entry to change the content. Fill binary value 10 00 00 00
9. Create an HTML file name google-search.html in path filled in entry (Defaults)
Example:

<script language="JavaScript">
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
if(external.menuArguments.event.shiftKey)
parentwin.open('http://www.google.com/search?hl=en&;lr=&ie=UTF-8&oe=utf-8&q='+ escape(str) + '&btnG=Google+Search');
else
parentwin.navigate('http://www.google.com/search?hl=en&;lr=&ie=UTF-8&oe=utf-8&q='+ escape(str) + '&btnG=Google+Search');
</script>

10. After all steps 1-9 completed, please test by opening your MSIE browser, and right click on selected words ...... Abrakadabra ... a menu item Google Search shows up. If you click it, will do googling for selected words. To search on new window, press & hold SHIFT button (after selecting words and before right clicking) then click menu "Google Search".

GUIDE
1. You may do this for other purposes such as query ke other sites http://www.kamus.web.id for instance by creating new HTML file with the following contents:

<script language="JavaScript">
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
if(external.menuArguments.event.shiftKey)
parentwin.open("http://www.kamus.web.id/english.asp?pilih=eng&;kata=" + escape(str));
else
parentwin.navigate("http://www.kamus.web.id/english.asp?pilih=eng&;kata=" + escape(str));
</script>

2. Or, launching new popup-window, execute programs, etc. by changing contexts value with certain value.

DISCLAIMER
1. Author is not responsible about any DAMAGE/DATA LOST caused by this experience.

0 Comments:

Post a Comment

<< Home