AutoHotkey Community

It is currently May 27th, 2012, 10:55 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Big Thankyou
PostPosted: January 17th, 2010, 8:35 am 
Hi NakariaSan,
like many people on the web I have been using Googles deskbar gadget for years even though Google stopped supporting it years ago when they introduced their new desktop bar. Now I have upgraded to windows 7 the old deskbar refuses to install and I suddenly found myself with no one key shortcut to put highlighted text into a Google text. You and Authotkey have solved this problem for me. Thankyou.
While your solution does not give me a little popup version of IE (don't really need it), it does open the searches in my favourite default browser (firefox) instead of IE which was the only possibility with the old discontinued Google deskbar.
Jim Davis


Report this post
Top
  
Reply with quote  
PostPosted: June 3rd, 2010, 5:32 pm 
Offline

Joined: June 3rd, 2010, 5:16 pm
Posts: 31
Folks,

Thank you for your posts. I am relatively new to AutoHotkey but wanted to contribute the following code that deals with non-alphanumeric characters, e.g. bill & mary.

Code:
;
; Searches for the highlighted text with Google in Firefox.
; If the text is a URL, it goes directly there.
;

#g::
ClipSaved := ClipboardAll   ; Save the entire clipboard
Clipboard =                 ; Clear the clipboard (useful for when there is no highlighted text)
Send ^c                     ; Copy the highlighted text to the clipboard
ClipWait 1                  ; Wait up to 1 second for the clipboard to contain data
if ErrorLevel               ; If there is no data in the clipboard after 1 second, exit
{
   MsgBox, The attempt to copy text onto the clipboard failed.
   return
}
SearchString := Clipboard   ; Assign the clipboard content to the variable
Clipboard := ClipSaved      ; Restore the original clipboard
ClipSaved =                 ; Free the memory in case the clipboard was very large
;
; Trim whitespace at either end
;
SearchString := RegExReplace(SearchString, "^\s+|\s+$")
;
; Prepare string for Google
;
if RegExMatch(SearchString, "\w\.[a-zA-Z]+(/|$)") ;contains .com etc
{
   if SubStr(SearchString, 1, 4) != "http"
      SearchString := "http://" . SearchString
}
else
{
;
; Google search does not deal directly with certain characters in the search string
; so they need to be replaced with their equivalent ASCII codes
;
   StringReplace, searchString, searchString, `%, `%25, All ; This needs to be at the start
   StringReplace, SearchString, SearchString, %A_Tab%, `%09, All
   StringReplace, SearchString, SearchString,  ", `%22, All
   StringReplace, SearchString, SearchString, `#, `%23, All
   StringReplace, SearchString, SearchString,  $, `%24, All
   StringReplace, SearchString, SearchString,  &, `%26, All
   StringReplace, SearchString, SearchString,  +, `%2B, All
   StringReplace, SearchString, SearchString, `,, `%2C, All
   StringReplace, SearchString, SearchString,  /, `%2F, All
   StringReplace, SearchString, SearchString,  :, `%3A, All
   StringReplace, SearchString, SearchString, `;, `%3B, All
   StringReplace, SearchString, SearchString,  =, `%3D, All
   StringReplace, SearchString, SearchString,  ?, `%3F, All
   StringReplace, SearchString, SearchString,  @, `%40, All
   StringReplace, searchString, searchString, %A_Space%, +, All
;
; Setup the Google search with an unquoted string
;
   SearchString := "http://www.google.com/search?&q=" . SearchString
;
; Uncomment the line below to setup the search with a quoted string
;
;   SearchString := "http://www.google.com/search?&q=" . "%22" . SearchString  . "%22"
}
;
; Open up new tab in Firefox with the Google search results
;
Run firefox.exe -new-tab %SearchString%
return


I hope someone finds this helpful.

Cheers,

Philip


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 17th, 2012, 6:39 am 
Anonymous wrote:
ok - i just shrinked down the origin script and am pretty sure that my ugly regex can be beautified, ....
I'm in love with you. You win the award for best use of a computer ever.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 6:52 am 
I changed my mind. all of you are awesome.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2012, 9:32 am 
Offline

Joined: April 1st, 2011, 9:32 am
Posts: 26
Hi all,

These Scripts and ideas look great and if I may, I would like to add my own search tool. This one allows you to highlight a keyword or some text and then depending on the hot key pressed, it will open on the webpage associated with that hotkey. The script will check to see if a browser is open (firefox or chrome) and open a new tab if it is or simply run the browser with the search if is not. I hope you like the script, it is on this previous post:

http://www.autohotkey.com/forum/viewtopic.php?t=79017


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 51 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group