Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Script to capture/collect URL and paste to Notepad on click


  • Please log in to reply
17 replies to this topic
Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012
Hi All,

Not sure if this is possible with AHK, but I'm looking to see if a script would allow say an 'Alt + MouseClick' on a URL, which would then paste the text link into a NotePad window, and subsequent links below the first.

Any ideas?
Ta,
Pilkojr

Ohnitiel
  • Members
  • 755 posts
  • Last active: Sep 08 2016 06:26 PM
  • Joined: 25 Aug 2011
FileAppend, clipboard variable, send command and clipwait. With these you should go fine.
Let us not be lazy. Someday it might just kill us.

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012

FileAppend, clipboard variable, send command and clipwait. With these you should go fine.


I've used 'Send' before, but none of the others :-)

#=::
FileAppend, %clipboard%`n, C:\Users\Pilkojr\Desktop\mg.txt
Return

This sends the URL I copy to the clipboard into the mg.txt file (if not currently opened). Where would I add code to make it do the above action if I use 'Alt+LeftMouseClick'?
Ta,
Pilkojr

Ohnitiel
  • Members
  • 755 posts
  • Last active: Sep 08 2016 06:26 PM
  • Joined: 25 Aug 2011
!Lbutton::
clipboard := "" clean clipboard
KeyWait, Alt ;waits for Alt button to be released
Send ^c ;copies whats selected
Clipwait ;wait for the clipboard to have content
FileAppend, %clipboard%`n, C:\Users\Pilkojr\Desktop\mg.txt
Return

This will only work if the url is on the browser bar.
Let us not be lazy. Someday it might just kill us.

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012

!Lbutton::
clipboard := "" clean clipboard
KeyWait, Alt ;waits for Alt button to be released
Send ^c ;copies whats selected
Clipwait ;wait for the clipboard to have content
FileAppend, %clipboard%`n, C:\Users\Pilkojr\Desktop\mg.txt
Return

This will only work if the url is on the browser bar.


So would the URL in the browser bar have to be fully selected, then Alt+LeftClick?

I'm trying to get the url/shortcut copied to the clipboard from a html link into notepad (if that makes sense).
Ta,
Pilkojr

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
This code requires AutoHotkey_L and jethrow's Acc Library (saved to your Lib folder), when you press the hotkey it will automatically write the URL for the link under the mouse to the text file:

!LButton::
Acc :=	Acc_ObjectFromPoint(child), state :=	Acc.accState(child)
if	state in 4194368,12582976
	FileAppend, %	Acc.accValue(child) "`n", C:\Users\Pilkojr\Desktop\mg.txt
return


Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012

This code requires AutoHotkey_L and jethrow's Acc Library (saved to your Lib folder), when you press the hotkey it will automatically write the URL for the link under the mouse to the text file:

!LButton::
Acc :=	Acc_ObjectFromPoint(child), state :=	Acc.accState(child)
if	state in 4194368,12582976
	FileAppend, %	Acc.accValue(child) "`n", C:\Users\Pilkojr\Desktop\mg.txt
return


Thank you for the code.

I've d/l'd and installed Autohotkey_L, but I'm unsure about the Acc Library file, and exactly where to put it. I gather the library file is the 'Acc.ahk' file. If so, which Lib folder do I need to put them in?
Ta,
Pilkojr

Ohnitiel
  • Members
  • 755 posts
  • Last active: Sep 08 2016 06:26 PM
  • Joined: 25 Aug 2011
Just a folder named Lib in the same path that you run the script.

Example:

If you run your script at My Documents, just create a folder named Lib there and put Acc.ahk inside it.
Let us not be lazy. Someday it might just kill us.

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012

Just a folder named Lib in the same path that you run the script.

Example:

If you run your script at My Documents, just create a folder named Lib there and put Acc.ahk inside it.


Thank you. Will try it now
Ta,
Pilkojr

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012
It's returning a whole bunch of errors. I'll try to screen capture and post
Ta,
Pilkojr

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012
Photot attached (I hope)
Ta,
Pilkojr

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012
Hi,

I was able to achieve the desired result using this code;

+MButton::
clipboard := "" ;clean clipboard
KeyWait, Shift ;waits for Shift button to be released
MouseClick, right
Sleep 200
Send {t}
Sleep 500
Send {Enter}
Sleep 1000
FileAppend, %clipboard%`n, C:\Users\Pilkojr\Desktop\mg.txt
;MsgBox, %clipboard% was sent to mg.txt
Return

It's probably a bit crude in the code world, but does what I need.

Thank you everyone for your input, as I was able to use bits and pieces to get it going.
Ta,
Pilkojr

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
They aren't errors, they're warnings. At the top of your script you'll find a line that says #Warn, put a semicolon in front of that line ;#Warn, save and restart your script. My code should run fine in either case.

Pilkojr
  • Members
  • 29 posts
  • Last active: May 16 2013 02:11 PM
  • Joined: 19 Feb 2012
Thank you, but it didn't paste anything into the mg.txt file
Ta,
Pilkojr

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
It's not going to "paste". Don't even have the text file open, my script automatically writes the URL to the file. Run the hotkey a few times, then open the text file and check for the URLs you hovered over.