thqby / ahk2_lib

MIT License
197 stars 26 forks source link

Update import_v1lib.ahk #24

Closed samfisherirl closed 11 months ago

samfisherirl commented 12 months ago

I created a simple if else to download the autohotkey v1 executable without installing, allowing to run ahkv1.

it may be better to pass this as a function option like @param download:=0 but nonetheless it should provide a more flexible path for using ahkv1 remotely.


if !FileExist(ahkv1runtime) {
               ; personally, I find my documents to be a safe place to download without windows defender massive flags 
               ; feel free to use something different 
    if !FileExist(A_MyDocuments "\Autohotkey.exe") {
        try {
                ; i hosted ahkv1 exe in a random github repo 
            Download("https://github.com/samfisherirl/download-Autohotkey-v2-Documentation/releases/download/v2/AutoHotkeyU64.exe",
                A_MyDocuments "\Autohotkey.exe")
            ahkv1runtime := A_MyDocuments "\Autohotkey.exe"
        } catch {
            throw Error("Could not find AutoHotkey v1 runtime")
        }
    } else {
        ahkv1runtime := A_MyDocuments "\Autohotkey.exe"
    }
}
thqby commented 12 months ago

I don't like to include the ability to download required files in library functions, unless it is a script specifically designed for downloading.