Tastaturkürzel für 7z „Zum Archiv hinzufügen…“

Tastaturkürzel für 7z „Zum Archiv hinzufügen…“

Ich möchte eine Tastenkombination für dieRechtsklick > Zum Archiv hinzufügen...Funktion von 7z im Windows-Datei-Explorer.

Dasfastfunktioniert mit AutoHotkey:

#z::
    SendInput {AppsKey}a{Enter}
    Return

Tatsächlich ist APPSKEYdann Amanchmal okay:

Bildbeschreibung hier eingeben

aber manchmal nicht in Ordnung, zum Beispiel, wenn die ausgewählte Datei ein Ordner ist:

Bildbeschreibung hier eingeben

wobei für den Buchstaben „A“ ein anderer Menüpunkt ausgewählt würde (hier „Zur MPC-HC-Wiedergabeliste hinzufügen“).

Wichtige Notizen:

  • Ich könnte in regedit.exeden verschiedenen Kontextmenüelementen manuell nach Dateien, Ordnern und jeder möglichen Dateierweiterung suchen (zu viele mögliche Erweiterungen!), aber das würde zu lange dauern, oder nicht? (*)

  • Ich habe es bereits versucht mit einem"Kaskadiertes Kontextmenü"für 7z (dies ist verfügbar im7z-Dateimanager > Extras > Optionen... > 7-ZipMenü), aber es ist noch schlimmer. Je nach Kontext sind die Buchstaben nicht gleich und dann ist es unmöglich, einen einheitlichen Hotkey zuzuordnen

  • Eine Lösung wäre, dass 7z sich &Add to archive...nicht nur Add to archive...in den Kontextmenüs registriert. Wenn ich mich recht erinnere, &hilft in den Kontextmenüeinstellungen von regedit die Verwendung einer Buchstabenkombination im Kontextmenü. Gibt es dafür eine Option? Leider scheint diese in 7-zip nicht direkt verfügbar zu sein.


(*) Wäre dies auch bei wenigen regeditAusgaben möglich? Also ersetzen Add to archive...durch &Add to archive? In wie vielen Schlüsseln/Werten soll dies erfolgen? In:

HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\7-Zip

Ich verstehe:

{23170F69-40C1-278A-1000-000100020000}

Kann das nützlich sein?

Antwort1

Versuche dies

#IfWinActive ahk_class CabinetWClass    ; explorer

    #z::
        ClipSaved := ClipboardAll       ; save the entire clipboard to the variable ClipSaved
        clipboard := ""                 ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
        Send, ^c                        ; copy selected item
        ClipWait, 1                     ; wait for the clipboard to contain data 
        if (!ErrorLevel)                ; If NOT ErrorLevel ClipWait found data on the clipboard
        {
            ; MsgBox, %clipboard%       ; display the path
            FileGetAttrib A, %clipboard%
            if InStr(A, "D")            ; is a folder
                SendInput {AppsKey}aa{Enter}
            else                        ; is a file
                SendInput {AppsKey}a{Enter}
        }
        else
            MsgBox, No file selected
        Sleep, 300 
        clipboard := ClipSaved         ; restore original clipboard
        VarSetCapacity(ClipSaved, 0)   ; free the memory
    return

#IfWinActive

https://www.autohotkey.com/docs/commands/_IfWinActive.htm https://www.autohotkey.com/docs/misc/Clipboard.htm#ClipboardAll https://www.autohotkey.com/docs/commands/FileGetAttrib.htm

BEARBEITEN

Dies sollte funktionieren, wenn wir mehrere Dateien zum ZIP-Verpacken auswählen:

#IfWinActive ahk_class CabinetWClass    ; explorer

    #z::
        folder := false
        file := false
        ClipSaved := ClipboardAll       ; save the entire clipboard to the variable ClipSaved
        clipboard := ""                 ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
        Send, ^c                        ; copy selected item
        ClipWait, 1                     ; wait for the clipboard to contain data 
        if (!ErrorLevel)                ; If NOT ErrorLevel ClipWait found data on the clipboard
        {
            Loop, Parse, Clipboard, `n  ; split by linefeed
            {
                LoopField := trim(A_LoopField, "`r`n") ; trim CRs/LFs
                FileGetAttrib A, %LoopField%
                if InStr(A, "D")        ; is a folder
                    folder := true
                else                    ; is a file
                    file := true
            }
            if (folder) 
            {
                if (file)              ; folders and files
                    SendInput {AppsKey}a{Enter}
                else                   ; only folders
                    SendInput {AppsKey}aa{Enter}
            }
            else if (file)             ; only files     
                SendInput {AppsKey}a{Enter}
        }
        else
            MsgBox, No file selected
        Sleep, 300 
        clipboard := ClipSaved         ; restore original clipboard
        VarSetCapacity(ClipSaved, 0)   ; free the memory
    return
    
#IfWinActive

verwandte Informationen