Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Downloaded Script

It's fairly simple.

I'd like to create a shortcut which:
1) Downloads a .ahk script from a website URL. (This script will change. It needs to get the latest version.)
2) Runs the script right away.

UrlDownloadToFile can download a file locally.
#Include can include the file in the script.
And Reload can restart the current script.

Of course, the best solution so far requires the use of multiple hotkeys. One to download and reload, and a second to run the script itself once it's downloaded.

Does anyone have any ideas how this could be done in one hotkey?

like image 534
azoundria Avatar asked Sep 03 '26 11:09

azoundria


1 Answers

The script that's run could have this in it. (launcher.ahk)

URLDownloadToFile, http://example.org/script.ahk, script.ahk
FileDelete timesince.dat
FileAppend, %A_Now%
Run script.ahk

In the top of script.ahk

FileRead, old_time, timesince.dat
If (!old_time) or (A_Now - old_time >= 10000) ; Expire in one hour minutes
{
    Run launcher.ahk
    ExitApp
}
; Actual code
like image 114
Brigand Avatar answered Sep 06 '26 04:09

Brigand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!