1.在文件夾「2」中,我想用Notepad ++打開選定的「example.html」文件。或2鼠標按鍵 - >編輯用記事本++AutoHotkey - 用Notepad ++打開html文件,然後查找並替換,然後保存,關閉。將其包含在另一個腳本中
2.然後查找單詞「大」和「小」取代它,保存並退出記事本++,並返回到文件夾「2」。
當選擇html文件時 - 單個快捷鍵如何實現2個第一步。沒有將它實現到另一個腳本中。
3.以及如何使用此腳本實現上述腳本,然後將其壓縮並移動到「FINAL」文件夾。因爲其中的一個文件是HTML文件,我需要執行上述兩個步驟。我想腳本應該在「發送^ a;全選」部分之前開始。
#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
有東西像'FileOpen'和'StringReplace'在AHK。你不需要打開任何外部程序(記事本)來解析和替換文件內容 – Blauhirn
根據你要做的事情,使用腳本語言會更簡單(** Perl **或** Python * *)替換內容,並啓動一個壓縮工具(例如** 7zip **)。你也可以從AHK啓動這個腳本。 –