Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FileURL(fn) {
- static INTERNET_MAX_URL_LENGTH := 2048
- local v
- VarSetStrCapacity(&v, INTERNET_MAX_URL_LENGTH)
- DllCall("Shlwapi.dll" (SubStr(fn, 1, 5) = "file:" ? "\PathCreateFromUrl" : "\UrlCreateFromPath")
- , "Str", fn, "Str", v, "UIntP", INTERNET_MAX_URL_LENGTH, "UInt", 0)
- VarSetStrCapacity(&v, -1)
- return v
- }
- #HotIf WinActive("ahk_class CabinetWClass")
- F7:: {
- hwnd := WinGetID("A")
- for win in ComObject("Shell.Application").Windows {
- if (win.HWND = hwnd) {
- sels := win.Document.SelectedItems
- cmd := '7zg a '
- if sels.Count = 0
- return
- if sels.Count > 1 {
- outpath := FileURL(win.LocationURL)
- cmd := cmd '"' outpath '/' win.LocationName '.7z" '
- } else {
- cmd := cmd '"' sels.Item(0).Path '.7z" '
- }
- for sel in sels {
- if sel.IsFileSystem
- cmd := cmd '"' sel.Path '" '
- else
- return
- }
- Run cmd
- }
- }
- }
- #HotIf
Advertisement
Add Comment
Please, Sign In to add comment