Trigger a download when url is in the clipoard Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Trigger a download when url is in the clipoard

19 Jan 2024, 16:33

I've got something that I want to do 5 or 6 times per day that would be nice to be able to automate.

There are various sites (twitter is one example) where I want to download the raw video. There are various sites that permit this, such as https://twdown.net/index.php

So, my idea is that I would like AutoHotkey to monitor the clipboard and trigger if a certain matching entry appears in the clipboard.
So for twitter / x, this would be if the clipboard ever contains a url starting with "https://twitter.com" or "https://x.com" and then also the string "/i/" somewhere else in that string (which indicates an image or video string):
regex: "^https://(twitter\.com|x\.com).*/i/"

Then, AutoHotkey would take over and would open https://twdown.net/index.php, then put the clipboard contents into the only input box there, press Download, then get the highest quality video on the page that opens and download that.

I think AutoHotkey is probably the best approach to doing this; any help would be appreciated.
ntepa
Posts: 478
Joined: 19 Oct 2022, 20:52

Re: Trigger a download when url is in the clipoard  Topic is solved

19 Jan 2024, 19:17

You can monitor the clipboard using OnClipboardChange.
This only does the first half of what you want:

Code: Select all

#Requires AutoHotkey v1.1.35+
#Persistent

OnClipboardChange("MonitorClipboard")

MonitorClipboard(dataType) {
    ; 0 = clipboard is empty.
    ; 1 = clipboard contains text.
    ; 2 = clipboard contains non-text such as a picture.
    if (dataType = 1) {
        if (A_Clipboard ~= "^https://(twitter\.com|x\.com).*/i/") {
            Run https://twdown.net/index.php
            ; UIA might help with setting the input box, and pressing the download button.
            ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=104999
        }
    }
}
william_ahk
Posts: 639
Joined: 03 Dec 2018, 20:02

Re: Trigger a download when url is in the clipoard

20 Jan 2024, 01:05

There are tons of Twitter video downloader extensions. Not everything is best done using AutoHotkey.
https://chromewebstore.google.com/search/twitter%20video%20download
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Re: Trigger a download when url is in the clipoard

20 Jan 2024, 05:30

Thanks for the great answers, I guess it might be easier to do with the extension, and that's probably good enough, though I still want to try with the monitor clipoard code, as that would offer me the best situation of all, just right-clicking on a video and copying the video url and then AutoHotkey doing the rest would be fantastic (plus I can think of a lot of uses for clipboar monitoring). :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Bing [Bot] and 139 guests