AutoHotkey Community

It is currently May 27th, 2012, 12:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: August 17th, 2004, 7:21 pm 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2004, 7:25 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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=n ... e=UTF-8&q=


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2004, 7:34 pm 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2004, 7:51 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2004, 3:54 am 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2004, 12:40 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2009, 4:38 pm 
Offline

Joined: October 29th, 2009, 4:34 pm
Posts: 1
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2009, 3:41 pm 
Online

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 3:53 pm 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 1:33 am 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cristi®, Google Feedfetcher, Stigg and 44 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