1。我在一个名为“2”的文件夹中,其中有不同类型的文件,路径如下:
“C:\用户\我\桌面\ Named_Folder \ 1 \ 2”
我想将所有这些文件放在Zip中,脚本应该如何,最后Zip将被称为“Named_Folder”,与路径中的文件夹相同?需要注意的是,“Named_Folder”每次都会有不同的名称。那么如何将zip命名为上面的两个目录。
2. :到目前为止我刚刚找到了将所有这些文件放入邮政编码的脚本:
#IfWinActive ahk_class CabinetWClass
Send ^a ; Select All
Send, {AppsKey} ; Press the "context menu" key
Sleep 100
Send n ; Select "Send to" with the "n" key
Sleep 100
Send {Right} ; Open "Sent to" with the "right arrow" key
Sleep 100
Send {Down} ; Select "Compressed (zipped) folder" with the "arrow down" key
Sleep 100
Send {Enter} ; Execute "Compressed (zipped) folder" with the "Enter" key
return
脚本应该如何将 1。和 2。步骤结合起来?用一个字母快捷方式。
所以最后结果应该是这样的:
3。然后我想将两个脚本(F2 F3甚至F1,如果它改变了什么)用一个字母的快捷方式组合在一起(4个第一行来自默认的AHK文件):
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#If WinActive("ahk_class CabinetWClass") ; explorer
F1::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := % window.Document.Folder.Self.Path
; IfExist, %Fullpath%\1\
Run, %Fullpath%\2
return
F2::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := % window.Document.Folder.Self.Path
; IfExist, %Fullpath%\1\2\
Run, %Fullpath%\1\2
return
#If
#IfWinActive ahk_class CabinetWClass
F3::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := % window.Document.Folder.Self.Path
if (SubStr(Fullpath, -3) = "\1\2")
{
StringReplace, Fullpath, Fullpath, :,
StringTrimRight, Fullpath, Fullpath, 4
StringSplit, folder_array, Fullpath, \,
MsgBox, % folder_array%folder_array0%
Send ^a ; Select All
Send, {AppsKey} ; Press the "context menu" key
Sleep 100
Send n ; Select "Send to" with the "n" key
Sleep 100
Send {Right} ; Open "Sent to" with the "right arrow" key
Sleep 100
Send {Down} ; Select "Compressed (zipped) folder" with the "arrow down" key
Sleep 100
Send {Enter} ; Execute "Compressed (zipped) folder" with the "Enter" key
Sleep 2000 ; wait 2 seconds
SendInput, % folder_array%folder_array0%
}
return
#IfWinActive
4. 然后提取zip(右键单击 - >上下文菜单 - > Extract to“与zip同名的文件夹”
因此,它会创建一个名为“NAMED_FOLDER”的文件夹,其中包含所有提取的内容。 我知道当我选择拉链并按下鼠标右键(打开上下文菜单)并按下字母“e”时,它可以正常工作。
5. 然后将此Zip和此新提取的文件夹移至文件夹“FINAL”中的桌面
最后用一个字母的快捷方式完成所有这5个步骤。那会为我做一些伏都教魔术,我真的需要这个工作流程。
答案 0 :(得分:0)
#IfWinActive ahk_class CabinetWClass
F4::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := window.Document.Folder.Self.Path
IfNotExist, %Fullpath%\1\2
{
MsgBox, The folder "%Fullpath%\1\2" doesn't exist
return
}
Run, %Fullpath%\1\2
WinWait, %Fullpath%\1\2
WinActivate, %Fullpath%\1\2
WinWaitActive,%Fullpath%\1\2
StringReplace, Fullpath2, Fullpath, :,
StringSplit, folder_array, Fullpath2, \,
FolderName = % folder_array%folder_array0%
; MsgBox, % folder_array%folder_array0%
FileCopyDir %Fullpath%\1\2, %A_Desktop%\FINAL\%FolderName%
; Sleep 2000 ; wait 2 seconds
Send ^a ; Select All
Send, {AppsKey} ; Press the "context menu" key
Sleep 100
Send n ; Select "Send to" with the "n" key
Sleep 100
Send {Right} ; Open "Sent to" with the "right arrow" key
Sleep 100
Send {Down} ; Select "Compressed (zipped) folder" with the "arrow down" key
Sleep 100
Send {Enter} ; Execute "Compressed (zipped) folder" with the "Enter" key
Sleep 2000 ; wait 2 seconds
SendInput, % folder_array%folder_array0%
Send {Enter}
SetTimer, Move_ZIP, 500
return
#IfWinActive
Move_ZIP:
IfExist, %Fullpath%\1\2\%FolderName%.zip
{
SetTimer, Move_ZIP, off
FileMove, %Fullpath%\1\2\%FolderName%.zip, %A_Desktop%\FINAL
}
return
或者这个:
#IfWinActive ahk_class CabinetWClass
F4::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := window.Document.Folder.Self.Path
IfNotExist, %Fullpath%\1\2
{
MsgBox, The folder "%Fullpath%\1\2" doesn't exist
return
}
Run, %Fullpath%\1\2
WinWait, %Fullpath%\1\2
WinActivate, %Fullpath%\1\2
WinWaitActive,%Fullpath%\1\2
StringReplace, Fullpath2, Fullpath, :,
StringSplit, folder_array, Fullpath2, \,
FolderName = % folder_array%folder_array0%
; MsgBox, % folder_array%folder_array0%
; Sleep 2000 ; wait 2 seconds
Send ^a ; Select All
Send, {AppsKey} ; Press the "context menu" key
Sleep 100
Send n ; Select "Send to" with the "n" key
Sleep 100
Send {Right} ; Open "Sent to" with the "right arrow" key
Sleep 100
Send {Down} ; Select "Compressed (zipped) folder" with the "arrow down" key
Sleep 100
Send {Enter} ; Execute "Compressed (zipped) folder" with the "Enter" key
Sleep 2000 ; wait 2 seconds
SendInput, % folder_array%folder_array0%
Send {Enter}
SetTimer, Move_ZIP, 500
return
#IfWinActive
Move_ZIP:
FileCreateDir %A_Desktop%\FINAL
IfExist, %Fullpath%\1\2\%FolderName%.zip
{
SetTimer, Move_ZIP, off
FileMove, %Fullpath%\1\2\%FolderName%.zip, %A_Desktop%\FINAL
Sleep 2000 ; wait 2 seconds
SetTimer, CopyDir, 500
}
return
CopyDir:
IfExist, %Fullpath%\1\2\%FolderName%.zip
return
SetTimer, CopyDir, off
FileCopyDir %Fullpath%\1\2, %A_Desktop%\FINAL\%FolderName%
return