KeyLimeTie Blog

Google Search in IE Context Menu

By Brian Pautsch – 10/22/2005. Posted to Code Snippets.

I spend a lot of time on Google and often jump to it from other sites to search for something I just read about. Wouldn't it be nice if I could just highlight text on a webpage, right-click and click "Search Google" from the context menu? Well now you can! About a year ago, I came across a Windows Tips and Tricks page and it explains a very easy way to do this.

Download code

To add "Google Search" to your Internet Explorer context menu (like Firefox has), here's how.
According to Microsoft, this method of adding context items should work as early as IE4.
Download the above code instead of creating the files from scratch (much easier).

Open notepad and paste the following code:
1Windows Registry Editor Version 5.00
2
3[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Google As Is]
4@="C:\\google_context_noquote.js"
5"Contexts"=hex:10
6
7[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Google w/Quotes]
8@="C:\\google_context_quote.js"
9"Contexts"=hex:10

You can change the paths to the js files if you want, just make sure you put the files where this says they are.
Save the file as google.reg, right-click it and select merge (or just double-click it).
Your registry was just updated to show two new entries in your IE context menu...now we need to create the js files.

Open notepad, paste the following code and save it as "google_context_noquote.js":
1<script language="javascript">
2// Get the window object where the context menu was opened.
3var oWindow = window.external.menuArguments;
4
5// Get the document object exposed through oWindow.
6var oDocument = oWindow.document;
7
8// Get the selection from oDocument.
9var oSelect = oDocument.selection;
10
11// Create a TextRange from oSelect.
12var oSelectRange = oSelect.createRange();
13
14// Get the text of the selection.
15var sNewText = oSelectRange.text;
16
17// Build Google QueryString
18var googleQ = "http://www.google.com/search?&q=" + sNewText;
19
20// Ask Google
21oWindow.open(googleQ);
22</script>

Open notepad, paste the following code and save it as "google_context_quote.js":
1<script language="javascript">
2// Get the window object where the context menu was opened.
3var oWindow = window.external.menuArguments;
4
5// Get the document object exposed through oWindow.
6var oDocument = oWindow.document;
7
8// Get the selection from oDocument.
9var oSelect = oDocument.selection;
10
11// Create a TextRange from oSelect.
12var oSelectRange = oSelect.createRange();
13
14// Get the text of the selection.
15var sNewText = oSelectRange.text;
16
17// Build Google QueryString
18var googleQ = "http://www.google.com/search?&q=%22" + sNewText + "%22";
19
20// Ask Google
21oWindow.open(googleQ);
22</script>

This will cause two new options to show up in the same menu that pops up when you have selected some text.
"Google As Is" sends a query to google with the selected text just as it is, no quotes.
"Google w/Quotes" does the same as above except it places quotes aroung the selected text.
You only need to restart your browser to get this to start working.

File Migrator Version 2.0

By Brian Pautsch – 10/1/2005. Posted to Applications.

I finally took this time to add more features to this application...and I think I'm done.
New features added:
 - Changed filtering to directional arrows (<, >, =)
 - Date span filtering
 - Datagrid color coding
    - White: not checked to migrate
    - Blue: checked to migrate
    - Green: current selected row
    - Red: files that might not want to be migrated (i.e. web.config)
 - Files that might not want to be migrated (i.e. web.config) are not checked to migrate by default

Download application

Below is a partial screenshot of the application (click image for large view).

 

Features coming soon:
Impersonation - Maybe one day...if I find time...

Please download and try the application out.

Photos on Flickr

More Photos »

Search Blog


Get Email Updates

Like what you read here at KeyLimeTie? Sign up for our email list!

Subscribe