Struggling with the script: left-click once to copy to clipboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
qwerties
Posts: 1
Joined: 25 Jul 2021, 05:20

Struggling with the script: left-click once to copy to clipboard

25 Jul 2021, 05:38

Hello there!

I'm working on the following script to be able to hold ctrl and single click to copy the marked word to clipboard. Problem is it's only working with plain text and not clickable URL words.

Code: Select all

^LButton::

Click 2

Send, ^c

return
To show you an example in the following article, I can click anywhere on the headline or article to copy words, but if I try and copy the name of the author Sheena at the top of the page, it does not work. I do not want to load/enter the page, just copy the word Sheena. Do you guys have a workaround to get this to work?

Article:
https://edition.cnn.com/2021/07/24/australia/australia-lockdown-covid-lucky-country-intl-cmd/index.html

Thanks a bunch.
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Struggling with the script: left-click once to copy to clipboard

27 Jul 2021, 21:54

That's tricky because the link is clickable. Below is a way to get the whole line.

Code: Select all

#IfWinActive ahk_exe chrome.exe
^+LButton::
KeyWait, Ctrl
KeyWait, Shift
WinGetPos,,, width
MouseGetPos, xpos, ypos
MouseClickDrag, L, 0, ypos, width - 30, ypos
Clipboard =
Send ^c
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
MouseMove, xpos, ypos
SoundBeep, 1700
Return
#IfWinActive
There could be some "advanced" methods to get the page's text and then identify which text matches the mouse's position, but I'd be skeptical about the reliability of that, due to variations in fonts & layout.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mannaia666, ntepa and 237 guests