Copying from clipboard with formatting

Get help with using AutoHotkey and its commands and hotkeys
Posts: 1
Joined: 22 Jan 2020, 08:28

Copying from clipboard with formatting

22 Jan 2020, 08:49

I'm trying to write a quick script that will take the contents of the keyboard, open up a web browser, and merge the text with a link to google translate, so that it is automatically converted from French to English.

For example, I'd highlight the following text
Bonjour Robert,

Je m'appelle Claude.

Comment allez vous?
Hit F2 + v, and have the web browser pop up.

At the moment, the clipboard copies this text with formatting (including spaces, line breaks, etc).

I'd like to be able to copy the text, then access it as:


I can then use this this string to directly open up a google translate page (appending this text to the weblink will make it open right away).

So far I have:

Code: Select all

F2 & v::   ;F2 + v
Send ^c   	;control-c (copy)
Sleep, 100   	; wait for Clipboard to update
Clipboard := Clipboard ; supposed to remove formatting
Output := " /sl=en&tl=pt#view=home&op=translate&sl=auto&tl=en&text="   Clipboard
Run, firefox.exe %Output%
return ;end
This currently opens each separate word as a new browser window.

If anybody could provide help in accessing/converting the text into the desired format, I'd be extremely grateful!
Posts: 605
Joined: 20 Oct 2016, 08:20

Re: Copying from clipboard with formatting

22 Jan 2020, 09:19

Code: Select all

Send ^c 
ClipWait, 1
Clipboard := RegExReplace(RegExReplace(Clipboard, " ","%20"),"`r`n","%0A")
Output := ""   Clipboard
Run, firefox.exe %Output%
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: Copying from clipboard with formatting

22 Jan 2020, 17:34

welcome everybody
Mr. Oldaner
Thanks for this great job. Actually, Mr. Robertoh1's question is important to me too and I thank you very much for your quick response .., and please allow me a question:
If the browser is already open on two pages of Google Translate, the first from English to French:

Second: from French to English:

And I want to activate the first page, from English to French:

Please kindly explain how this is done.
Thanks in advance

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Elgin, flyingDman, Google [Bot], MrNerd, Sefer, theholyscripture and 67 guests