Creating hyperlink file (.url) to webpage (e.g. from Chrome to Windows Explorer) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Creating hyperlink file (.url) to webpage (e.g. from Chrome to Windows Explorer)

08 Jan 2020, 19:53

Hi,

I’d appreciate your assistance to create a hyperlink file to a webpage, as shown in this short screencast: http://bit.ly/2QYd61f

The workflow:
- In Google Chrome, pressing a shortcut (e.g. alt+F12) would grab the webpage hyperlink, changing the focus to Windows Explorer (File Manager).
- In Windows Explorer, the link would be created having the default .url file format, in which

File name.url =
Webpage title (e.g. Life Is Beautiful Ending - YouTube.url)

File content =
[InternetShortcut]
URL=https://www.youtube.com/watch?v=K7FW7t-N4jI

Is it possible to achieve?

Thank you!
Carlos
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Creating hyperlink file (.url) to webpage (e.g. from Chrome to Windows Explorer)  Topic is solved

09 Jan 2020, 03:51

Code: Select all

#If WinActive("ahk_class Chrome_WidgetWin_1")
!F12::CreateChromeHyperlink()
#If

CreateChromeHyperlink()
{
    WinGetActiveTitle, WinTitle
    Send, {Ctrl Down}l{Ctrl Up}
    Clipboard := ""
    Sleep 50
    Send, {Ctrl Down}c{Ctrl Up}
    ClipWait, 1
    FileAppend, % "[InternetShortcut]`nURL=" . Clipboard, % StrReplace(WinTitle, " - Google Chrome") . ".url"
}
This should get you started. You can edit as needed. (add blockinput, save path, check errorlevel etc)
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: Creating hyperlink file (.url) to webpage (e.g. from Chrome to Windows Explorer)

09 Jan 2020, 22:06

Hi @Xtra,

Thank you very much for the script and directions!

Could you please provide further assistance to adjust your script to send "page title" + "URL" to clipboard instead?

Example:
Webpage title (e.g. Life Is Beautiful Ending - YouTube.url)
URL (e.g. https://www.youtube.com/watch?v=K7FW7t-N4jI)

Clipboard output:
Life Is Beautiful Ending - YouTube
https://www.youtube.com/watch?v=K7FW7t-N4jI
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Creating hyperlink file (.url) to webpage (e.g. from Chrome to Windows Explorer)

09 Jan 2020, 23:31

Added another function:

Code: Select all

#If WinActive("ahk_class Chrome_WidgetWin_1")
+F12::ClipChromeHyperlink()
!F12::CreateChromeHyperlink()
#If

ClipChromeHyperlink()
{
    WinGetActiveTitle, WinTitle
    Send, {Ctrl Down}l{Ctrl Up}
    Clipboard := ""
    Sleep 50
    Send, {Ctrl Down}c{Ctrl Up}
    ClipWait, 1
    Clipboard := StrReplace(WinTitle, " - Google Chrome") . "`n" . Clipboard
}

CreateChromeHyperlink()
{
    WinGetActiveTitle, WinTitle
    Send, {Ctrl Down}l{Ctrl Up}
    Clipboard := ""
    Sleep 50
    Send, {Ctrl Down}c{Ctrl Up}
    ClipWait, 1
    FileAppend, % "[InternetShortcut]`nURL=" . Clipboard, % StrReplace(WinTitle, " - Google Chrome") . ".url"
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: fiendhunter and 227 guests