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

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



Joined: 17 Aug 2004
Posts: 18

PostPosted: Tue Aug 17, 2004 7: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: 10464

PostPosted: Tue Aug 17, 2004 7: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: 18

PostPosted: Tue Aug 17, 2004 7: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: 10464

PostPosted: Tue Aug 17, 2004 7: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: 18

PostPosted: Wed Aug 18, 2004 3: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: Mon Aug 23, 2004 12:40 am    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
Display posts from previous:   
Post new topic   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