
Quiero crear un atajo de teclado para elHaga clic derecho > Agregar al archivo...característica de 7z, en el Explorador de archivos de Windows.
Estecerca defunciona con AutoHotkey:
#z::
SendInput {AppsKey}a{Enter}
Return
De hecho APPSKEY, Aa veces está bien:
pero a veces no está bien, por ejemplo, cuando el archivo seleccionado es una Carpeta:
para lo cual se seleccionaría otro elemento del menú para la letra "A" (aquí, "Agregar a la lista de reproducción MPC-HC").
Notas importantes:
Podría buscar manualmente en
regedit.exe
los distintos elementos del menú contextual Archivos, Carpetas y cada extensión de archivo posible (¡demasiadas extensiones posibles!), pero esto sería demasiado largo... ¿no? (*)Ya lo intenté con un"Menú contextual en cascada"para 7z (está disponible en el7z-Administrador de archivos > Herramientas > Opciones... > 7-Zipmenú), pero las cosas son aún peores. Dependiendo del contexto, las letras no son las mismas y entonces es imposible asociar una tecla de acceso rápido consistente
Una solución sería que 7z se registrara
&Add to archive...
en lugar de soloAdd to archive...
en los menús contextuales. Si no recuerdo mal,&
en la configuración del menú contextual de regedit es lo que ayuda al menú contextual a utilizar un atajo de letras. ¿Hay una opción para esto? Lamentablemente, esto no parece estar disponible directamente en 7-zip.
(*) ¿Aún sería posible con pocas regedit
ediciones? es decir, reemplazar Add to archive...
por &Add to archive
? ¿En cuántas claves/valores se debe hacer esto? En:
HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\7-Zip
Veo:
{23170F69-40C1-278A-1000-000100020000}
¿Puede ser útil esto?
Respuesta1
Prueba esto
#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
EDITAR
Esto debería funcionar si seleccionamos varios archivos para ZIP:
#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