Currently I use several variations of this script to search a selected word or phrase (in any program) on various websites (google, dictionaries, specialized websites, etc. etc.).
*I currently rewrite the entire script for each website.* But I know that there is a way to write it out once only, as a function?, and use variables? for the command and the website searched. That's what I would like to achieve.
So:
Code: Select all
#+g:: > search http www.google.ca / Broken Link for safety
#+w:: > search https www.wordreference.com /fren/ Broken Link for safety
#+t:: > search https www.btb.termiumplus.gc.ca /tpv2alpha/alpha-eng.html?lang=eng Broken Link for safety
ANY HELP APPRECIATED! THANKS!
Here is the search script I'm currently using:
Code: Select all
#+g::
;Copy Clipboard to prevClipboard variable, clear Clipboard.
prevClipboard := ClipboardAll
Clipboard =
;Copy current selection, continue if no errors.
SendInput, ^c
ClipWait, 2
if !(ErrorLevel) {
;Convert Clipboard to text, auto-trim leading and trailing spaces and tabs.
Clipboard = %Clipboard%
;Clean Clipboard: change carriage returns to spaces, change >=1 consecutive spaces to +
Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "\s+","+")
;Open URLs, Google non-URLs. URLs contain . but do not contain + or .. or @
if Clipboard contains +,..,@
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http www.google.ca / Broken Link for safetysearch?q=%Clipboard%
else if Clipboard not contains .
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http www.google.ca / Broken Link for safetysearch?q=%Clipboard%
else
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %Clipboard%
}
;Restore Clipboard, clear prevClipboard variable.
Clipboard := prevClipboard
prevClipboard =
return