Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Make a Google It tool to perform web searches from TextPad

 
Post new topic   Reply to topic    Community Forum Index -> Tips
View previous topic :: View next topic  
Author Message
KurtM



Joined: 29 Nov 2006
Posts: 1
Location: Houston, TX

PostPosted: Thu Nov 30, 2006 1:00 am    Post subject: Make a Google It tool to perform web searches from TextPad Reply with quote

First post for me here -- so be gentle! (although I am a long time TextPad user, circa 2001).

I don't think this subject has been addressed in the forums yet. I did a search and didn't find any discussion of it. Here goes...

Sometimes when I am in the middle of writing VBScript or other administrative scripting, I forget how to use a particular function or method. Othertimes I just am curious how someone else has approached the same problem I am programming for. Like most folks I know in the industry, I usually just open up my browser and Google for it to see what pops up.

Being a bit of the lazy sort, I wanted to be able to be able to search for a topic or keyword on the Internet from right within TextPad, without leaving my open document window and typing something in elsewhere. Ideally the solution wouldn't require me to have to do much more than what I currently do on an Internet Explorer page -- which is right-click on a highlighted term or phrase in the web page and select Google Search from the resulting pop-up menu.

Thank goodness for TextPad's customizable Tools Menu. Although I couldn't come up with a slick 'right-click' method to perform a web search from within an open document in Textpad, I believe I came up with something that's just as easy and functionally as elegant.

There are basically just two steps involved in creating your own Google It tool for the TextPad Tools Menu:

  1. Add a custom tool entry to the Tools Menu.

  2. Configure its properties to invoke Internet Explorer and pass search parameters to Google's search engine.


Let's detail the above steps. The first one is very easy once you understand what type of menu item to add. (Note, unlike creating a new document class you don't need to close any open documents to customize the tool menu -- see How to Customize the Tools Menu in Help for more details.)

  1. Add a custom Tool entry:

    1. From the Configure menu, choose Preferences (or use the two-key shortcut Ctrl+Q, P)

    2. Select "Tools" in the left-hand window of the dialog box that just opened up.

    3. From the Tools form on the right-hand side, click the "Add" button and then from the list that drops down select "Program...".

    4. Using the File Selection dialog box that appears next, navigate your way to where your \Program Files folder is located and expand the Internet Explorer folder found there.

    5. Select the file "iexplore.exe" and then click on the dialog box's "Open" button to complete the program file selection process and add the new entry to the Tools list.

    6. You should now see a highlighted entry titled "Iexplore" at the bottom of the Tools list in the preferences dialog box. If you haven't clicked anywhere else yet, click once on the name "Iexplore" and rename it to "Google It" or whatever you'd like to call it.

      Don't worry if you did get in a hurry and lost focus on the Iexplore entry by clicking somewhere else or by clicking the Apply button. To rename any entry just click twice on it (like a really slow double-click) and type in the new name.

    7. Now click on the "Apply" button and your Google It tool entry will appear when you expand the Tools item in the left-hand window of the preferences dialog box.

  2. Now to edit the Google It tool properties:

    1. Still keeping the Preferences dialog box open, expand the Tools item in the left-hand window and select "Google It" (or whatever you named it earlier).

    2. You'll find that some of the properties have already been filled out for you by the Add Tools Wizard. That's okay. We really only need to change one of them anyways -- the "Parameters" property.

    3. In the "Parameters" field, enter the following:
      Code:
      -nohome http://www.google.com/search?num=100&hl=en&lr=&q=$SEL

    4. Don't worry about the rest of the settings. You can leave the three checkboxes unchecked (Prompt for parameters, Run minimized, Save all documents first) and the "Initial folder" doesn't really apply so it's ok to leave it at $FileDir.

    5. Now just click on the "OK" button in the Preferences dialog box to close it.


Congratulations! You should now have a Tools menu entry called Google It. Let's try it out.

Go to any open document window in TextPad and double-click on a word -- like say on SWBemServices as seen in the following code snippet...
Code:
Dim objWMIService     ! As WbemScripting.SWbemServices

and then click on the Tools menu to select "Google It" from the drop down list (or if your version is like mine you'll see a shortcut key hint next to the menu item that you can use next time. Mine is Ctrl+6 for Google It).

That should have just brought up an invocation of iexplore.exe and passed the formed Google URL parameter to it almost as if it were an HREF link. Neat huh?

This works because of the Tool Parameter Macro we specified when defining the properties of the tool. Remember the $SEL part of the URL specification? In the TextPad Help for Tool Parameter Macros it is defined as "Selected text in the active document."

So whatever you have selected in text will be passed to Google (limited to the first line of selected text in case you made a multiple-line selection). You can even select partial lines of code and successfully find things. I found this so slick that I set out to try and deliberately foul up a search by selecting wierd partial code. Really was not ever able to foul it up!

Try this out. Select part of a line of code from something like I show below.
Code:
Set colPings = objWMIService.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & strComputer & "'")

Really trying to throw it for a loop with unmatched parens and qoutes, I selected only this portion of the above code snippet and then used the Google It tool on it...
Code:
.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address =

and I'll be danged if it didn't work! I not only got results for code samples that looked just like mine, but I also saw examples of better approaches for what I was trying to do.

A couple of notes about some of the techniques used in the above example. The reason I selected "Program..." rather than DOS Command, is because I'm assuming that Helios is putting the invocation into its own thread using some process-creation API, like CreateProcessEx. The is preferable to essentially creating two seperate process threads and memory allocations (one for the cmd.exe process and one for iexplore) which is what you'd do by using the DOS Command. Minor thing, but one is more efficient.

The switch "-nohome" used on iexplore.exe is to prevent it from first trying to open up a home page and then referencing our URL. You may see the "-new" switched used by some, but it's really not necessary here. You're getting a fresh process thread anyways. You could also use the "-k" switch (but I don't know why you would want to). That will open up IE in kiosk mode -- no status bar, no buttons, no menus. Netscape also responds to the "-k" switch in the same manner.

You may not want a few of the Google switches I illustrated with, especially if your native language is not English. Remove the "&hl=en" parameter from the Google url to default to your language setting in Google preferences.

I usually do not like to limit my searches to just English language pages so that is why I've added the "&lr=" limit parameter. Remove it if you want the searches to obey your set preferences for limiting searches to a specific set of languages.

Lastly, if you prefer some other number of search results to come up than 100 you can obviously change that too by specifying a different number for "num=100"


Hope everyone found this useful and instructional! Happy Googling.

Cheers,

Kurt Mayer
Back to top
View user's profile Send private message
OnlyTextPad



Joined: 20 May 2006
Posts: 41
Location: Helsinki

PostPosted: Thu Feb 08, 2007 1:10 pm    Post subject: Awesome ! Here the configuration with Opera also Reply with quote

AWESOME ! HERE THE CONFIGURATION WITH OPERA
REPLACE DIFFERENT OPERA PATH IF YOU HAVE ANY


Command:C:\Program Files\Opera\Opera.exe
Parameters:http://www.google.com/search?hl=en&client=opera&rls=en&hs=pun&q="$SEL"
Starting folder : C:\Program Files\Opera\

OK HERE THE COPY PASTE OF THE REG FILE FOR THE MOST LAZY ONES (ON YOUR OWN RISK !!! )
=====================COPY PASTE START
Code:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Helios\TextPad 4\Tools\19]
"Properties"=hex:00,00,00,00,69,80,00,00,40,00,00,00
"MenuText"="GoogleItWithOpera"
"Command"="C:\\Program Files\\Opera\\Opera.exe"
"Parameters"="http://www.google.com/search?hl=en&client=opera&rls=en&hs=pun&q=\"$SEL\""
"Folder"="C:\\Program Files\\Opera\\"
"RE"=""



=====================COPY PASTE STOP


Last edited by OnlyTextPad on Wed Mar 07, 2007 1:51 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
bveldkamp



Joined: 11 Apr 2003
Posts: 350
Location: Utrecht, The Netherlands

PostPosted: Thu Feb 08, 2007 1:25 pm    Post subject: Reply with quote

That's pretty useful; additionally, to start the default system browser, do this:
Configure > Preferences > Tools
Add > DOS Command
Type Google > OK > Apply
In the tree on the left, select Tools > Google
On the right:
Parameters: start http://www.google.com/search?q=$SELWORD
Check "Run Minimized" and "Close DOS Window", uncheck all others
Apply / OK
Code:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Helios\TextPad 4\Tools\7]
"Properties"=hex:01,00,00,00,5d,80,00,00,46,00,00,00
"MenuText"="Google"
"Command"="cmd.exe"
"Parameters"="start http://www.google.com/search?q=$SELWORD"
"Folder"="$FileDir"
"RE"=""

_________________
Berend Veldkamp
The Netherlands


Last edited by bveldkamp on Mon Jan 21, 2008 1:29 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
FrassHead



Joined: 05 Apr 2006
Posts: 3

PostPosted: Wed Feb 14, 2007 7:12 pm    Post subject: Reply with quote

Any idea why this doesn't work with Firefox? I'd rather not even allow iExplorer to un on my machine.

FH
Back to top
View user's profile Send private message
OnlyTextPad



Joined: 20 May 2006
Posts: 41
Location: Helsinki

PostPosted: Wed Feb 14, 2007 7:30 pm    Post subject: Try this only for firefox Reply with quote

The reason is the dummy space in C:\Program Files
you would need to invoke the program with the start command
Trying to add dos command http://www.google.fi/search?q=$SEL works for me
Code:

[HKEY_CURRENT_USER\Software\Helios\TextPad 4\Tools\20]
"Properties"=hex:01,00,00,00,6a,80,00,00,e8,00,00,00
"MenuText"="GOOGLEITWITHFIREFOX"
"Command"="cmd.exe"
"Parameters"="start /max firefox http://www.google.com/search?q=$SEL"
"Folder"="$FileDir"
"RE"=""
Back to top
View user's profile Send private message Visit poster's website
textpad-fan



Joined: 21 Apr 2007
Posts: 25

PostPosted: Sun Jan 20, 2008 6:36 pm    Post subject: Reply with quote

Try this in the parameters field in order to use the Google's Define switch:

Code:
-nohome http://www.google.com/search?num=100&hl=en&safe=off&q=define%3A$SEL&btnG=Search
Back to top
View user's profile Send private message
aabe



Joined: 03 May 2008
Posts: 1

PostPosted: Sat May 03, 2008 9:02 pm    Post subject: Google IT tool Reply with quote

Very Happy Good Tool! Works great!
Back to top
View user's profile Send private message
HerNameWasTextPad



Joined: 18 Apr 2008
Posts: 59

PostPosted: Sun May 04, 2008 4:04 am    Post subject: Reply with quote

Don't ya just love this program?

When I hear some users say things like, "TextPad is an aging program," I honestly don't know what they mean. Maybe they just haven't discovered for themselves what TextPad can do.

Thanks for sharing this in the forum.
_________________
I came in on 4.5 in 2001, moved to 4.7.2 in 2004, moved to 4.7.3 in 2007, moved to 5.4 in 2010, and am excited about 2013. I've said it many times before, and I'll say it many times again: "I love this program."
Back to top
View user's profile Send private message
HerNameWasTextPad



Joined: 18 Apr 2008
Posts: 59

PostPosted: Sun May 04, 2008 5:44 am    Post subject: Reply with quote

By the way, just to make sure that the palette is complete, so to speak, are you aware of the default ability to position the cursor on an active document's URL and right-click to select the open command?

Alternatively, position the cursor on a URL and Ctrl+Shift+G.

Help -> Help Topics -> Index -> URL -> Display

With both this and the new Google It tool, manually launching a browser can be nothing more than an occasional diversion!
_________________
I came in on 4.5 in 2001, moved to 4.7.2 in 2004, moved to 4.7.3 in 2007, moved to 5.4 in 2010, and am excited about 2013. I've said it many times before, and I'll say it many times again: "I love this program."
Back to top
View user's profile Send private message
mandela10



Joined: 06 Jun 2009
Posts: 1

PostPosted: Sat Jun 06, 2009 11:55 pm    Post subject: Reply with quote

Nice tool. i have just tried it, it works great.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Tips All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB