program that copies a text and search for it in the browser

Get help with using AutoHotkey and its commands and hotkeys
Bakr
Posts: 5
Joined: 04 Jan 2018, 09:50

program that copies a text and search for it in the browser

04 Jan 2018, 10:15

Hi everyone,

i want a program that copies a selected text (from a MS Word file for example) and search for it in the browser
i wrote this script but it didn't work

Tab::
send, ^c
sleep, 200
send, {LWin}
sleep, 1000
send, web:
send, {Space}
sleep, 200
send, {ctrl down}v{ctrl up}
sleep, 200
send, {Enter}

Return

the line "send, ^c" sends the letter c instead of copying the selected text.
i have tried writing "send, {ctrl down}c{ctrl up}" but it also sends the letter c instead of copying the selected text.
Any help please??
User avatar
joedf
Posts: 7796
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: program that copies a text and search for it in the browser

04 Jan 2018, 11:47

[Topic moved to Ask For Help]
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: program that copies a text and search for it in the browser

04 Jan 2018, 11:58

this works good for me:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#z::
browser = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

;### Search for selection, or open URL ###
;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, %browser% https://duckduckgo.com/?q=%Clipboard%
    else if Clipboard not contains .
      Run, %browser% https://duckduckgo.com/?q=%Clipboard%
    else
      Run, %browser% https://duckduckgo.com/?q=%Clipboard%
  } 
;Restore Clipboard, clear prevClipboard variable.
  Clipboard := prevClipboard
  prevClipboard =
return

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], lusu2789, zvit and 34 guests