I made an Autohotkey script to generate .foo_youtube files from the clipboard.
;Ctrl + Shift + X
^+x::
;Retreives the url from the clipboard.
text1 := Clipboard
;Escapes slashes.
text1 := StrReplace(Clipboard, "/", "\/")
;Escapes quotation marks.
qte := Chr(34)
slsqte := "\" . Chr(34)
text1 := StrReplace(text1, qte, slsqte)
;Adds the rest of the string.
text1 := "{" . qte . "url" . qte . ":" . qte . text1 . qte . ",}"
;Gets the id of the currently active window.
ActiveHwnd := WinExist("A")
;Initializes a variable for saving the filepath of the currently open Windows Explorer window.
activeExplorerPath := ""
;Looks through all open Windows Explorer windows.
for w in ComObjCreate("Shell.Application").Windows
;If one of them has the same hwnd as the active window, it is the active window.
If (ActiveHwnd = w.hwnd)
{
;We retreive the current path of it.
activeExplorerPath := w.Document.Folder.Self.Path
;We use the path to generate a complete filepath for saving our file.
filePath := activeExplorerPath . "\" . "foo_youtube.foo_youtube"
;To avoid appending the text multiple times in the same file, we delete the file if it has already been created.
FileDelete, %filePath%
;We then create the file again, and paste our text.
FileAppend, %text1%, %filePath%
}
Return
- Have the script running in the background
- Go to a youtube video and copy the url. for example: https://www.youtube.com/watch?v=lNXEHsv8UI4
- Go the folder where you wish to save the .foo_youtube file, and press Ctrl+Shift+X
- It will generate a .foo_youtube file with the minimum information needed: {"url":"https:\/\/www.youtube.com\/watch?v=lNXEHsv8UI4",}
- Open the file and the component will generate the rest.