View difference between Paste ID: rf7eYufJ and KN6yrBJW
SHOW: | | - or go back to the newest paste.
1
FileURL(fn) {
2
    static INTERNET_MAX_URL_LENGTH := 2048
3
    local v
4
    VarSetStrCapacity(&v, INTERNET_MAX_URL_LENGTH)
5
    DllCall("Shlwapi.dll" (SubStr(fn, 1, 5) = "file:" ? "\PathCreateFromUrl" : "\UrlCreateFromPath")
6
        , "Str", fn, "Str", v, "UIntP", INTERNET_MAX_URL_LENGTH, "UInt", 0)
7
    VarSetStrCapacity(&v, -1)
8
    return v
9
}
10
11
#HotIf WinActive("ahk_class CabinetWClass")
12
F7:: {
13
    hwnd := WinGetID("A")
14
    for win in ComObject("Shell.Application").Windows {
15
        if (win.HWND = hwnd) {
16
            sels := win.Document.SelectedItems
17-
            cmd := '7zg a '
17+
            cmd := '7zg.exe'
18
            if sels.Count = 0
19
                return
20
            if sels.Count > 1 {
21
                outpath := FileURL(win.LocationURL)
22-
                cmd := cmd '"' outpath '/' win.LocationName '.7z" '
22+
                cmd := cmd ' a "' outpath '/' win.LocationName '.7z" '
23
            } else {
24-
                cmd := cmd '"' sels.Item(0).Path '.7z" '
24+
                cmd := cmd ' a "' sels.Item(0).Path '.7z" '
25
            }
26
            for sel in sels {
27
                if sel.IsFileSystem
28
                    cmd := cmd '"' sel.Path '" '
29
                else
30
                    return
31
            }
32
            Run cmd
33
        }
34
    }
35
}
36
#HotIf