Ещё более усовершенствованный вариант скрипта. В контекстном меню иконки в трее есть возможности:
+ использовать диалог (переключатель);
+ использовать буфер обмена (переключатель);
+ отображать уведомления об успехе/неуспехе (переключатель);
+ поместить скрипт в автозагрузку (переключатель).
Имя папки может редактироваться непосредственно в Проводнике, точно так же, как это происходит при обычном создании папки без скриптов.
#SingleInstance Force
#MaxThreadsPerHotkey 5
SplitPath, A_ScriptName, , , , strIniFileName
strIniFileName = %strIniFileName%.ini
Menu, Tray, Icon, Shell32.dll, 4
Menu, Tray, Tip , Press F7 in Explorer to create New folder
Menu, Tray, NoStandard
Menu, Tray, Add, Use dialog, mhUseDialog
IniRead, boolUseDialog, %A_ScriptDir%\%strIniFileName%, Main, UseDialog, %False%
If (boolUseDialog)
Menu, Tray, Check, Use dialog
Else
Menu, Tray, Uncheck, Use dialog
Menu, Tray, Add, Use clipboard, mhUseClipboard
IniRead, boolUseClipboard, %A_ScriptDir%\%strIniFileName%, Main, UseClipboard, %True%
If (boolUseClipboard)
Menu, Tray, Check, Use clipboard
Else
Menu, Tray, Uncheck, Use clipboard
Menu, Tray, Add, Show notification, mhShowNotification
IniRead, boolShowNotification, %A_ScriptDir%\%strIniFileName%, Main, ShowNotification, %True%
If (boolShowNotification)
Menu, Tray, Check, Show notification
Else
Menu, Tray, Uncheck, Show notification
;Menu, Tray, Add, Change folder, mhChangeFolder
;IniRead, boolChangeFolder, %A_ScriptDir%\%strIniFileName%, Main, ChangeFolder, %True%
;If (boolChangeFolder)
; Menu, Tray, Check, Change folder
;Else
; Menu, Tray, Uncheck, Change folder
;Menu, Tray, Disable, Change folder
Menu, Tray, Add
Menu, Tray, Add, Start with &Windows, mhAutorun
IniRead, boolAutorun, %A_ScriptDir%\%strIniFileName%, Main, Autorun, %False%
If (boolAutorun)
{
Menu, Tray, Check, Start with &Windows
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Run, F7, "%A_ScriptFullPath%"
}
Else
{
Menu, Tray, Uncheck, Start with &Windows
RegDelete, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Run, F7
}
Menu, Tray, Add
Menu, Tray, Add, Quit, mhQuit
Menu, Tray, Default , Quit
If boolShowNotification
{
TrayTip, ,Press F7 in Explorer to create New folder, 3, 1
Sleep, 3 * 1000
TrayTip,
}
;=============================================================================
;=============================================================================
#IfWinActive, ahk_class CabinetWClass
F7::
#IfWinActive, ahk_class ExploreWClass
F7::
WinGet, intHWND, ID, A
WinGet, strProcessName, ProcessName, ahk_id %intHWND%
IfEqual, strProcessName, explorer.exe
{
ControlGetText, strParentFolder, Edit1, ahk_id %intHWND%
IfExist, %strParentFolder%
{
If boolUseClipboard
{
StringReplace, strFolder, Clipboard, " , , All
SplitPath, strFolder , strFolder
}
Else
{
Loop
{
If A_Index = 1
strFolder = Новая папка
Else
strFolder = Новая папка (%A_Index%)
IfNotExist, %strParentFolder%\%strFolder%
Break
}
}
If boolUseDialog
{
InputBox, strFolder, Создание папки, Создать папку, , , 120, , , , , %strFolder%
IfEqual, ErrorLevel, 0
IfNotEqual, strFolder,
Gosub, subCreateFolder
}
Else
{
Gosub, subCreateFolder
}
}
}
Return
;=============================================================================
;=============================================================================
mhUseDialog:
boolUseDialog := Not boolUseDialog
Menu, Tray, ToggleCheck, Use dialog
IniWrite, %boolUseDialog%, %A_ScriptDir%\%strIniFileName%, Main, UseDialog
Return
;=============================================================================
;=============================================================================
mhUseClipboard:
boolUseClipboard := Not boolUseClipboard
Menu, Tray, ToggleCheck, Use clipboard
IniWrite, %boolUseClipboard%, %A_ScriptDir%\%strIniFileName%, Main, UseClipboard
Return
;=============================================================================
;=============================================================================
mhShowNotification:
boolShowNotification := Not boolShowNotification
Menu, Tray, ToggleCheck, Show notification
IniWrite, %boolShowNotification%, %A_ScriptDir%\%strIniFileName%, Main, ShowNotification
Return
;=============================================================================
;=============================================================================
;mhChangeFolder:
; boolChangeFolder := Not boolChangeFolder
; Menu, Tray, ToggleCheck, Change folder
; IniWrite, %boolChangeFolder%, %A_ScriptDir%\%strIniFileName%, Main, ChangeFolder
;Return
;=============================================================================
;=============================================================================
mhAutorun:
boolAutorun := Not boolAutorun
Menu, Tray, ToggleCheck, Start with &Windows
IniWrite, %boolAutorun%, %A_ScriptDir%\%strIniFileName%, Main, Autorun
If (boolAutorun)
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Run, F7, "%A_ScriptFullPath%"
Else
RegDelete, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Run, F7
Return
;=============================================================================
;=============================================================================
mhQuit:
ExitApp, 0
Return
;=============================================================================
;=============================================================================
subCreateFolder:
IfNotExist, %strParentFolder%\%strFolder%
{
ControlGet, intOldItemsCount, List, Count, SysListView321, ahk_id %intHWND%
FileCreateDir, %strParentFolder%\%strFolder%
If (ErrorLevel = 0) And (FileExist(strParentFolder . "\" . strFolder))
{
Loop, 1000
{
ControlGet, intNewItemsCount, List, Count, SysListView321, ahk_id %intHWND%
If Not (intNewItemsCount == (intOldItemsCount + 1))
Sleep, 10
Else
Break
}
ControlFocus, SysListView321, ahk_id %intHWND%
Send, {End}
ControlGet, strSelected, List, Selected Col1, SysListView321, ahk_id %intHWND%
If (strSelected == strFolder)
Send, {F2}
Gosub, subSuccesInfo
}
Else
Gosub, subShowError
}
Else
Gosub, subShowError
Return
;=============================================================================
;=============================================================================
subSuccesInfo:
If boolShowNotification
{
TrayTip, Folder [%strFolder%] created successfully, in [%strParentFolder%], 3, 1
Sleep, 3 * 1000
TrayTip,
}
Return
;=============================================================================
;=============================================================================
subShowError:
TrayTip, Can't create folder [%strFolder%], in [%strParentFolder%], 5, 3
Sleep, 5 * 1000
TrayTip,
Return
;=============================================================================