 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
myrison
Joined: 03 Nov 2009 Posts: 2
|
Posted: Tue Nov 03, 2009 2:49 am Post subject: Pass quotes in variable to Google search |
|
|
Hi all - this is probably a total noob question, but I cannot figure it out from reading the tutorial. Can someone please review this very simple script and advise how it can be altered such that items in quotes (i.e. "test search text") will pass the quotation marks as well as the search text?
Right now any time I submit an entire search query in quotes or a query that includes a partial items in quotes, nothing is returned.
| Quote: | ~LControl::
if (A_PriorHotkey <> "~LControl" or A_TimeSincePriorHotkey > 200)
{
; Too much time between presses, so this isn't a double-press.
KeyWait, LControl
return
}
InputBox, UserInput, GoogleSearch, Enter Google Query., , 640, 130
if ErrorLevel
return
else
Run, http://www.google.com/search?q=%UserInput%
return
|
Thank you!
Jason |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Nov 03, 2009 3:28 am Post subject: |
|
|
Post example of what you are trying to enter in Google.
We can't read you mind.
I entered"string" in the input box and it sent exactly what I typed. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Tue Nov 03, 2009 3:50 am Post subject: |
|
|
| Anonymous wrote: | Post example of what you are trying to enter in Google.
We can't read you mind. | You obviously can't read his post either.
| myrison wrote: | Can someone please review this very simple script and advise how it can be altered such that
items in quotes (i.e. "test search text") will pass the quotation marks as well as the search text? |
myrison, try this script
the hardest part was putting spaces between words;
I found that without "StringReplace" command, the spaces disappear
| Code: | InputBox, UserInput, GoogleSearch, Enter Google Query., , 640, 130
if ErrorLevel
return
else
{
msgbox user %UserInput%
StringReplace, OutputVar, UserInput, %a_space% , `%20, 1
msgbox out %OutputVar%
Run, http://www.google.com/search?q= `"%OutputVar%`"
}
return
|
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Tue Nov 03, 2009 6:47 am Post subject: |
|
|
Another possibility (untested):
| Code: | if InStr(UserInput,Chr(34)) ; Chr(34) is quotation mark
StringReplace, UserInput, UserInput, % Chr(34), `%22 |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
firace
Joined: 08 Feb 2009 Posts: 28
|
Posted: Tue Nov 03, 2009 9:54 am Post subject: |
|
|
here's my take (i've been using this script for months and it works just fine for me):
Win+G activates the input box.
#g::
send {Ctrl}
inputbox, st,Google Search,,,,95,,,,,weather miami
if ErrorLevel
return
StringReplace, st, st, `", `%22, all
run http://www.google.com/search?q=%st%
return |
|
| Back to top |
|
 |
myrison
Joined: 03 Nov 2009 Posts: 2
|
Posted: Tue Nov 03, 2009 12:45 pm Post subject: |
|
|
Thank you all for the quick replies. (even the one complaining that I was not asking my question clearly)
I tested all of them and sinkfaze & lazygeek, yours both work flawlessly. Leef_me - thank you for the response as well, but strangely, your code exhibits the same problems my current code does.
Test query is this: | Quote: | | "test search" text outside of quotes |
Leef - the first ouput box returns | Quote: | | user "test search" outside of quotes | and then the second output box returns | Quote: | | out "test%20search"%20outside%20of%20quotes |
However, when posted to Google, the variable passed is | Quote: | | "test search outside of quotes | It is missing the second quote for some reason.
In any case, please don't feel the need to troubleshoot further as I do have a working solution now.
Thanks again guys for the help. I used to install Google Desktop solely for the ability to use the "double control" keyboard shortcut that would pop up a Google search box. That program comes with a a lot of clutter though just to get the keyboard shortcut. This is MUCH more lightweight and efficient.
Thanks again! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|