use text from clipboard to search on a particular website

Get help with using AutoHotkey and its commands and hotkeys
cukr
Posts: 2
Joined: 10 Sep 2018, 09:06

use text from clipboard to search on a particular website

10 Sep 2018, 09:29

Hello,

I have discovered Autokey and it is a fantastic tool for speeding up work on a computer. I have no problem with using Phrases, but I would like to use Scripts.

I often use searching for on particular websites, so it would be great to use text in my clipboard to search for on a specific web. I used the following code with a definition of getting clipboard selection and then using this clipboard for searching on a specific site. However, it seems to miss something because the script encounters an error when I use it.

Code: Select all

text = clipboard.get_selection()
CaSearch:="https://old.sketchengine.co.uk/admin/ca/userprofile/?q=%s" % text
Can you please navigate me?
bordop
Posts: 10
Joined: 03 Jun 2018, 23:03
GitHub: bordop

Re: use text from clipboard to search on a particular website

12 Sep 2018, 19:05

try

Code: Select all

text := Clipboard
Run "https://old.sketchengine.co.uk/admin/ca/userprofile/?q=%s" . %text%
bordop
Posts: 10
Joined: 03 Jun 2018, 23:03
GitHub: bordop

Re: use text from clipboard to search on a particular website

12 Sep 2018, 19:10

Can't test your site, but this works:

Code: Select all

text := "maps"
Run "www.google.com/%text%"
iseahound
Posts: 614
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: use text from clipboard to search on a particular website

12 Sep 2018, 19:22

try this

Code: Select all

#g:: Google()

   Copy() {
      c := ClipboardAll
      Clipboard := ""             ; Must start off blank for detection to work.
      Send, ^c
      ClipWait 0.5
      if ErrorLevel
         return
      t := Clipboard
      Clipboard := c
      VarSetCapacity(c, 0)
      return t
   }

   Google(data := "", prefix := "") {
      text := (data == "") ? copy() : data
      url := RegExReplace(text, "^\s+|\s+$")                ; Trim whitespace
      if RegExMatch(url, "^(http|ftp|telnet)") {
         ; Do nothing if it already looks like a URL
      } else {
         ; Escape the query string. Could escape more, but this seems sufficient for Chrome
         StringReplace, url, url, `%, `%25, All
         StringReplace, url, url,  &, `%26, All
         StringReplace, url, url,  +, `%2B, All
         url := "https://www.google.com/search?&q=" . prefix . url
      }
      Run %url%
      return
   }
cukr
Posts: 2
Joined: 10 Sep 2018, 09:06

Re: use text from clipboard to search on a particular website

20 Sep 2018, 10:15

Hi,

thanks for your suggestions, unfortunately, none of them work. Meanwhile, I created only this little script

Code: Select all

text = clipboard.get_selection()
keyboard.send_keys("https://www.google.com/search?q=%s" % text)
which is only at halfway to the aim because I need to open manually a new tab in a browser.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], CluelessHotKeyUser, helming, mikeyww, omareg94, songdg, yumuffin and 41 guests