Using copy for a link that you cannot right click and 'copy'?

Get help with using AutoHotkey and its commands and hotkeys
chef423
Posts: 213
Joined: 28 Aug 2016, 12:10
Google: Christopher Smith
GitHub: chef23

Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 13:05

The 'Link' is a 16 digit number, on a website that is clickable, but when you mouse over it and right click, there is no direct COPY option.
Only the standard:
Save Link as...
Copy Link
etc

Is there a way for AHK to 'force' copy that 16 digit number?

When I use my mouse and and left click (from the left of the first #) and drag to the right, obviously I get the highlight I want and then I can press CRTL+C or simply right click and select copy.

Id rather not have the mouse pointer involved here, so I can keep the code clean and as error-less as possible. I have tried the Shift and arrow, no luck.

Thanks in advance.
chef423
Posts: 213
Joined: 28 Aug 2016, 12:10
Google: Christopher Smith
GitHub: chef23

Re: Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 13:31

Code: Select all

MouseClickDrag, left, 481, 197, 624, 197
	Send, ^c
This 'works' but its hardly what I want...

EDIT: actually it does not work because the 'click' is lifted before I can COPY the text
Last edited by chef423 on 27 Apr 2017, 14:48, edited 1 time in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 14:06

You could try this (requires the Acc library):

Code: Select all

q:: ;get text from element/control/window under cursor
oAcc := Acc_ObjectFromPoint()
;hWnd := Acc_WindowFromObject(oAcc)
vText1 := vText2 := ""
try vText1 := oAcc.accName(0)
try vText2 := oAcc.accValue(0)
;Clipboard := vText1 "`r`n" vText2 "`r`n"
Clipboard := "accName: " vText1 "`r`n" "accValue: " vText2 "`r`n"
return
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

Otherwise you could use Internet Explorer and COM.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
chef423
Posts: 213
Joined: 28 Aug 2016, 12:10
Google: Christopher Smith
GitHub: chef23

Re: Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 14:47

jeeswg wrote:You could try this (requires the Acc library):

Code: Select all

q:: ;get text from element/control/window under cursor
oAcc := Acc_ObjectFromPoint()
;hWnd := Acc_WindowFromObject(oAcc)
vText1 := vText2 := ""
try vText1 := oAcc.accName(0)
try vText2 := oAcc.accValue(0)
;Clipboard := vText1 "`r`n" vText2 "`r`n"
Clipboard := "accName: " vText1 "`r`n" "accValue: " vText2 "`r`n"
return
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

Otherwise you could use Internet Explorer and COM.
Thank you.

I am using this:

Code: Select all

MouseClickDrag, L, 481, 197, 630, 197, 50
	SetMouseDelay, 100
	Send, ^c
BUT the 'click' is released before I can ^c the text....

hmmm...

(I have to use Google Chrome for this project)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 15:03

Maybe you can play about with this code to achieve what you want. I'm still having an issue that if LButton is held down, ctrl+c to copy doesn't work, although perhaps this can be resolved.

Code: Select all

q:: ;drag and copy
MouseMove, 481, 197
Send {LButton Down}{Shift Down}
Sleep 100
MouseMove, 630, 197
Sleep 100
Clipboard := ""
Send {LButton Up}{Shift Up}^c
ClipWait, 3
MsgBox, % Clipboard
return
[EDIT:] I'm not sure why I thought Shift was necessary, [EDIT 2: shift+arrows is needed to select text via the keyboard] anyway, this script may actually work for you in its current form:

Code: Select all

q:: ;drag and copy
MouseMove, 481, 197
Send {LButton Down}
MouseMove, 630, 197
Clipboard := ""
Send ^c{LButton Up}
ClipWait, 3
MsgBox, % Clipboard
return
Last edited by jeeswg on 27 Apr 2017, 16:51, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 15:44

If you're using Firefox (haven't tested this on other web browsers) you can jump around between links and other elements on a web site simply by pressing Tab. Then you'll get the normal right-click option using AppsKey. Maybee that works.
chef423
Posts: 213
Joined: 28 Aug 2016, 12:10
Google: Christopher Smith
GitHub: chef23

Re: Using copy for a link that you cannot right click and 'copy'?

27 Apr 2017, 17:20

Thank you everyone...

Return to “Ask For Help”

Who is online

Users browsing this forum: 4k3or3et, AHKStudent, Bing [Bot], boiler, davehotkeys, doubledave22, elbeau, nacken012 and 46 guests