AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Google The Clipboard Content

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
thinkstorm



Joined: 17 Aug 2004
Posts: 38

PostPosted: Tue Aug 17, 2004 6:21 pm    Post subject: Google The Clipboard Content Reply with quote

Copy a text snippet into the clipboard and google with Control-G

TC

Code:
#g::
   googleLinkStart = C:\PROGRA~1\INTERN~1\IEXPLORE.EXE http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=
   AutoTrim, On
   searchTerm = %clipboard%
   if searchTerm =
   {
      MsgBox, 48, Search Google, No text in clipboard to google., 2
      return
   }
   StringReplace, searchTerm, searchTerm, `r`n, +, all
   StringReplace, searchTerm, searchTerm, %A_SPACE%, +, all
   searchTerm = %googleLinkStart%%searchTerm%
   Run, %searchTerm%
Return
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Tue Aug 17, 2004 6:25 pm    Post subject: Reply with quote

Nice. A minor improvement might be to make it browser-neutral by omitting the path. I think this replacement line might be enough:

googleLinkStart = http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=
Back to top
View user's profile Send private message Send e-mail
thinkstorm



Joined: 17 Aug 2004
Posts: 38

PostPosted: Tue Aug 17, 2004 6:34 pm    Post subject: Reply with quote

I would not do that! if you already have an internet explorer open (if you use IE ;)), the script will use that window. adding the path to the program opens definitely a new window.

It's a pain to have the 8.3 path in here, though, fiddled around a little bit and couldn't figure out how to put a path with spaces up here (and adding a parameter)

TC
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Tue Aug 17, 2004 6:51 pm    Post subject: Reply with quote

Quote:
It's a pain to have the 8.3 path in here, though, fiddled around a little bit and couldn't figure out how to put a path with spaces up here (and adding a parameter)

That's odd. I tried the following single-line script on XP and it worked okay:
Run %ProgramFiles%\Internet Explorer\IEXPLORE.EXE www.google.com

If you're using some other OS, maybe there's an OS-specific problem I should look into.
Back to top
View user's profile Send private message Send e-mail
thinkstorm



Joined: 17 Aug 2004
Posts: 38

PostPosted: Wed Aug 18, 2004 2:54 am    Post subject: Reply with quote

Hm,
you're absolutely right, it works like a blast! Maybe this was with an earlier version - the script is kind of old... Or I made another stupid mistkae, maybe I forgot the ',' after the RUN or something, anyway, the script works fine :)

TC
Back to top
View user's profile Send private message
porche911
Guest





PostPosted: Sun Aug 22, 2004 11:40 pm    Post subject: Reply with quote

Here's a slightly modified version that will open a google search in a new tab in Mozilla Firefox, or else open a new broswer window.

#g::
clipboard =
Send, ^c
ClipWait, 1

if ErrorLevel <> 0
{
MsgBox, 48, Search Google, No text in clipboard to google., 2
return
}

googleLinkStart = http://www.google.com/search?hl=en&lr=UTF-8&q=
searchTerm = %clipboard%
AutoTrim, On
WinGetActiveTitle, Title
IfInString, Title, Mozilla Firefox
{
SetKeyDelay, 10
send ^t^l
send %googleLinkStart%%searchTerm%{Enter}
}
else
{
StringReplace, searchTerm, searchTerm, `r`n, +, all
StringReplace, searchTerm, searchTerm, %A_SPACE%, +, all
searchTerm = %googleLinkStart%%searchTerm%
Run, %searchTerm%
}
Return
Back to top
RevAaron



Joined: 29 Oct 2009
Posts: 1

PostPosted: Thu Oct 29, 2009 3:38 pm    Post subject: Reply with quote

I'm a bit late to the game (ok, 5 years), but I've been using this version for Firefox, based on the OP's. porche911's didn't work for me, and looked like a bit of a kludge anyway; command arguments generally make more sense than keyboard shortcuts, when possible.

Code:

#g::
   googleLinkStart = U:\apps\Firefox-3.5.3-portable\App\Firefox\firefox.exe -new-tab

http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=
   AutoTrim, On
   searchTerm = %clipboard%
   if searchTerm =
   {
      MsgBox, 48, Search Google, No text in clipboard to google., 2
      return
   }
   StringReplace, searchTerm, searchTerm, `r`n, +, all
   StringReplace, searchTerm, searchTerm, %A_SPACE%, +, all
   searchTerm = %googleLinkStart%%searchTerm%
   Run, %searchTerm%
Return


I'm using it mostly with Portable Firefox, but it works fine with an installed instance. Just replace "U:\apps\Firefox-3.5.3-portable\App\Firefox" with "C:\Program Files\Mozilla\Firefox" or whatever the path is to the folder with firefox.exe.

Thanks all for this!
Back to top
View user's profile Send private message
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Sat Oct 31, 2009 2:41 pm    Post subject: Reply with quote

Code:
#G::
run explorer about:tabs,,max


This will open your accellerator page, including search/mail etc, any clipboard contents is stored in the [show copied text field]
Back to top
View user's profile Send private message
thinkstorm



Joined: 17 Aug 2004
Posts: 38

PostPosted: Thu Mar 11, 2010 2:53 pm    Post subject: Reply with quote

Someone mailed me to adjust the script in case you want to reuse an existing Google search window.... Unfortunately I couldn't figure out an easy way to go through all IE/Firefox tabs to look for the right tabs, so only if the foremost tab is a Google search you'll reuse it...

Code:
#g::
   AutoTrim, On
   searchTerm = %clipboard%
   If searchTerm =
   {
      MsgBox, 48, Search Internet, No text in clipboard to search., 2
      Return
   }
   C_BROWSER="C:\Program Files\Mozilla Firefox\firefox.exe" ;replace that with the browser of your choice
   linkStart=http://www.google.com/search?complete=1&hl=en&q=
   linkEnd=&btnG=Google+Search
   searchTerm := RegExReplace(searchTerm, "[\s&]+", "+")
   searchTerm = %linkStart%%searchTerm%%linkEnd%
   SetTitleMatchMode,2 ;A window's title can contain WinTitle anywhere inside it to be a match.
   ; These are the four options of windows - add your own and copy&paste accordingly
   wintitle1 := "Google - Mozilla Firefox ahk_class MozillaUIWindowClass"
   wintitle2 := "Google Search - Mozilla Firefox ahk_class MozillaUIWindowClass"
   wintitle3 := "Google - Windows Internet Explorer ahk_class IEFrame"
   wintitle4 := "Google Search - Windows Internet Explorer ahk_class IEFrame"
   Loop, 4 {
      wintitle := wintitle%a_index%
      ifWinExist, %wintitle%
      {
         SetKeyDelay, -1
         WinActivate
         BlockInput, On
         SendInput, !d
         SendRaw, %searchTerm%
         SendInput, {enter}
         BlockInput, Off
         Return
      }
   }
   Run, %C_BROWSER% "%searchTerm%"
Return

_________________
Cheers,

Thorsten
Back to top
View user's profile Send private message
Cody - not logged in
Guest





PostPosted: Fri Mar 12, 2010 12:33 am    Post subject: Reply with quote

This is what I use, if you press Alt+H, it will copy anything highlighted and past it into the edit control (of course you can edit what's automatically copied into there if you like) and in the gui there are 5 buttons, one to search autohotkey, one for google, one for wikipedia, one for dictionary and thesaurus (dictionary and thesaurus uses m-w.com).
When the interface pops up, you can press alt+g for google, alt+w for wikipedia, and so on.

Code:

/*
Alt+h Prompts for highlighted word to search at AutoHotkey, Google, Wikipedia, Dictionary, Thesaurus             
*/

!h::
Send ^c
Send {Shift Down}
Send {Home}
Send {Shift Up}
Gui, Add, Text, x10 y10 w415 h20 Center, Search Autohotkey's site documentation or search from Google:
Gui, Add, Edit, yp+20 wp vSearch,
Gui, Add, Button, yp+30 w77 h26 gfSearch, &AutoHotkey
Gui, Add, Button, xp+85 wp hp ggSearch, &Google It!
Gui, Add, Button, xp+85 wp hp gwSearch, &Wikipedia
Gui, Add, Button, xp+85 wp hp gdSearch, &Dictionary
Gui, Add, Button, xp+85 wp hp gtSearch, &Thesaurus
Gui, Show, AutoSize Center, Quick Search
Send ^v
Return

fSearch:
Gui, Submit
Gui, Destroy
Run
, % "http://www.autohotkey.com/search/search.php?site=0&path=&result_page=search.php&query_string="
. RegExReplace(RegExReplace(Search,"#","`%23"),A_Space,"`%20")
. "&option=start&search=Search"
return

wSearch:
Gui, Submit
Gui, Destroy
Run
, % "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search="
. RegExReplace(RegExReplace(Search,"#","`%23"),A_Space,"`%20")
. "&fulltext=Search"
return

gSearch:
Gui, Submit
Gui, Destroy
Run, http://www.google.com/search?q=%Search%
return

dSearch:
Gui, Submit
Gui, Destroy
Run, http://www.merriam-webster.com/dictionary/%Search%
return

tSearch:
Gui, Submit
Gui, Destroy
Run, http://www.merriam-webster.com/thesaurus/%Search%
Return

GuiClose:
Gui, Destroy
return
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group