Hi all,
I need to develop a script which pastes the path of a file as an hyperlink rather than simple text which could works at least in word and onenote. Is there any way to do it?
Pasting the path of a file as hyperlink
Re: Pasting the path of a file as hyperlink
Here is some documentation you can read on file hyperlinkshttps://msdn.microsoft.com/en-us/librar ... S.85).aspx
For example you could paste the following into your web address and get a link to your c drive
At this point you can use https://autohotkey.com/docs/commands/StringReplace.htm for all the replacement you would need to do it.
For example you could paste the following into your web address and get a link to your c drive
Code: Select all
file:///C:/
Re: Pasting the path of a file as hyperlink
I made it. What I would like to improve is the control of the displayed text. Is it possible?
Re: Pasting the path of a file as hyperlink
You can use WinClip. It has a SetHTML function which allows you to easily put an HTML-formatted link onto the clipboard.
Re: Pasting the path of a file as hyperlink
I made this script:TygerByte wrote:Here is some documentation you can read on file hyperlinkshttps://msdn.microsoft.com/en-us/librar ... S.85).aspx
For example you could paste the following into your web address and get a link to your c driveAt this point you can use https://autohotkey.com/docs/commands/StringReplace.htm for all the replacement you would need to do it.Code: Select all
file:///C:/
Code: Select all
^+c:: ; { <-- ~ Copy the path of a file and paste it as hyperlink ~
SendInput, ^c
Sleep 100
Clipboard := Clipboard
Prova := Clipboard
StrBeg := "file:///"
Clipboard := StrBeg . Clipboard
Return
The file protocol has some problems for this link, where all the following text is pasted, but link ends at the string effect.
file:///d:\Documenti\Universita\Materiale_per_articoli\Mitas\M - Papers\Effect of inflating pressione on tractive performance of bias-ply tires.PDF
Therefore, the link is not effective. Is there any character which should be added to specify which is the text to include in the link? In the file protocol link you provided, there is no information about it.
Thanks
Best regards
Re: Pasting the path of a file as hyperlink
you may need to do additional steps to make it it a working link, replacing the spaces with %20 for example: See https://en.wikipedia.org/wiki/Percent-encoding for more information and codes if need be
Code: Select all
; ...
StringReplace, Clipboard, Clipboard,\,/,All ; replace \ with /
StringReplace, Clipboard, Clipboard,%A_Space%,`%20,All ; replace \ with /
Clipboard:=StrBeg . Clipboard
; ...
Re: Pasting the path of a file as hyperlink
that is perfect! thanks!Guest wrote:you may need to do additional steps to make it it a working link, replacing the spaces with %20 for example:See https://en.wikipedia.org/wiki/Percent-encoding for more information and codes if need beCode: Select all
; ... StringReplace, Clipboard, Clipboard,\,/,All ; replace \ with / StringReplace, Clipboard, Clipboard,%A_Space%,`%20,All ; replace \ with / Clipboard:=StrBeg . Clipboard ; ...
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Pasting the path of a file as hyperlink
I also usual turn to WinClip for any fancy clipboard manipulation.egocarib wrote:You can use WinClip. It has a SetHTML function which allows you to easily put an HTML-formatted link onto the clipboard.
Here are some examples:
Code: Select all
; https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
#Include <WinClipAPI>
#Include <WinClip>
#f12::
WinClip.Clear()
WinClip.SetText("www.ahkscript.org")
WinClip.SetHTML("<a href=""http://www.ahkscript.org"">Linky to AHK</a>")
WinClip.Paste()
return
#f11::
WinClip.Clear()
WinClip.SetBitmap(A_Desktop "\Temp\1024x1024.jpg")
WinClip.Paste()
return
#f10::
Picture := A_Desktop "\Temp\1024x1024.jpg"
html=
(
<font size="2" face="Calibri" color="black">
<p>Best Regards,<br>Have a nice day!<br>More Greetings and e-mails and that sort of stuff<br><br>
<b><font size="2">
Your Name</b><br>
<a href="mailto:[email protected]">[email protected]</a><br>
<img src=%Picture% alt="My picture";">
)
WinClip.SetHTML(html)
WinClip.Paste()
return
::OS::
WinClip.Clear()
WinClip.SetText("Best Regards,`nHave a nice day!`nMore Greetings and e-mails and that sort of stuff`n`n")
WinClip.Paste()
WinClip.Clear()
WinClip.SetBitmap(A_Desktop "\Temp\1024x1024.jpg")
WinClip.Paste()
return
Esc::ExitApp
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Who is online
Users browsing this forum: Araphen and 312 guests