Тема: AHK: YourFastIcons: Быстрое назначение папкам собственных значков
Намедни обнаружив, что скриптов по такому важному делу, как присвоение значков папкам на форуме нет, а специализированное ПО использует в основном dll несподручные, затрудняющие добавление собственных и тд — горячо восхотел показать вам "свой", как мне кажется, единственно удобный.
А моего тут, собственно, мало: код представляет собой слегка переделанный и заточенный под нужды иконазначений (словцо моё всецело) англо-форумный Ultra Fast Anything-Launcher, предназначавшийся было для скоростного запуска чего бы то ни было, через создаваемый файл индекса. Стоит ли говорить, что после некоторых моих манипуляций этот последний преобразился...
Предполагается два варианта его использования — выбрав нужные папки запускать (.exe) из контекстного меню, либо (.ahk) из-другого-скрипта/по-хоткею.
После того как вы внесёте необходимые изменения в созданный при первом запуске ini-файл, перезапущенный скрипт отсканирует список папок, указанный в параметре "PathList" (файла ini), и создаст индекс значков в том же каталоге.
ОПИСАНИЕ КОМАНД КОНТЕКСТНОГО МЕНЮ, КНОПОК И МЕНЮ В ТРЕЕ
* Apply this icon to folder — Назначить выделенный значок папке (при этом файл значка скопируется в неё, сделав, таким образом, присвоенный значок постоянным);
* Set Default — Вернуть обычный значок (все произведенные изменения будут удалены);
* Open containing folder — Открыть содержащую значок папку;
* Edit Icon — Открыть файл значка в редакторе;
* Scan folders — Сканировать папки (указанные в параметре "PathList");
* Scan-statistics — Показать статистику сканирования;
* Edit settings — Открыть файл конфигурации для редактирования;
ГОРЯЧИЕ КЛАВИШИ
* CapsLock + i — Сменить значок для выбранной (перед выводом окна) папки/папок;
* Alt + Ctrl + i — Выход;
Есть предпросмотр иконок и быстрый поиск.
P.S.
Иногда (крайне редко, по счастью), при выборе большого количества папок может вылезти второй, — это надо прямо сказать, — окна GUI экземпляр. Но что особенно прискорбно: AHK_L почему-то значки ни этого, ни того образца (с англо-форума) не демонстрирует, — уж не знаю, что с этим поделать...
#SingleInstance ignore
AutoTrim, Off
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
MainWnd = YourFastIcons
SetKeyDelay, 0
id320 = -1
Process, Priority,, High
Menu, Tray, Icon, Shell32.dll, 210 ;23 57 172 210
Menu, Tray, Tip, %MainWnd%
GoSub, FldLst2ClpBrd
;;JWJ - Avoids drawing GUI again
if id320 <> -1 ;not the 1st run
GoSub, Hide320
Start320:
IniFile = %A_ScriptDir%\%MainWnd%.ini
IniGui_IniFile:=IniFile
GoSub, ReadIni
IfNotExist, %IniFile%
GoSub, WriteIni
;AlwaysScan := ExpandVars(AlwaysScanI)
PathListX := ExpandVars(PathList)
OpenFolderWithX := ExpandVars(OpenFolderWith)
StringRight, ExtChk, A_ScriptFullPath, 4
IfEqual, ExtChk, .exe
If ShellIntegration
RegWrite, REG_SZ, HKCR, Folder\shell\YourFastIcons\command,, "%A_ScriptFullPath%" "`%1"
Else
RegDelete, HKCR, Folder\Shell\YourFastIcons,
;create scanned result list on first run
IfNotExist, %A_ScriptDir%\%ListFile%
GoSub, ButtonScan
;Check scan date and create menus
GoSub, CheckScanDate_and_CreateMenus
;;JWJ - Avoids drawing GUI again
if id320 <> -1 ;not the 1st run
GoSub, Hide320
;///////////////////////////////////////////////////////////////////////////////////
;Read scan file in ItemList
GoSub, ReadScanFile
;Make Gui
GuiX :=
GuiY :=
LVGuiW := 472 ;GuiW - 12
GuiMargin := 21
GuiH := 620
GuiW := LVGuiW + (GuiMargin * 2) ;275 volt, 10 115 - 232 645
LVGuiH := GuiH - 2*GuiMargin - 48 - 20 - 20 + 46 ;64
StatusY := GuiH - GuiMargin +10 - 24
Status2Y := GuiH - GuiMargin +10 - 7 - 20
FEditX := GuiW - GuiMargin - 150
FEditTY := GuiMargin + 5
IconSize := 1
Gui, -Caption +Border +LastFound +ToolWindow
mgH := WinExist()
Gui, Color, %GuiColor%
GuiTextC = CBlack
gui, font, s10, Tahoma
Gui, Add, Text, % "x" GuiMargin " y" GuiMargin-8, Search:
Gui, Add, Edit, % "x+15 y" GuiMargin-4 " w175 CBlack vCurrText gGetText",
gui, font, s8 %GuiTextC%, Tahoma
Gui, Add, ListView, Icon -Multi x%GuiMargin% y+2 w%LVGuiW% h%LVGuiH% vSelItem gSelection AltSubmit Background%ListColor% C%ListTextC%, Name|Ext|Folder
Gui, Font
gui, font, %GuiTextC% ;this line prevents theme on bottom CheckBox buttons - but ok.
Gui, Add, Button,x0 y0 w0 h0
Gui, Add, Text, % "x" GuiMargin+0 " y" GuiMargin+8 " w60 h12 vResults",
Gui, Add, CheckBox, % "x" FEditX+68 " y" Status2Y " vShowTTip Right w83", Show &Tooltip
Gui, Add, Picture, % "X" GuiW " Y" GuiMargin+45 " W200 H480", %Pth%
Gui, Add, Text, x%GuiMargin% y%Status2Y%, Max item&s:%A_Space%
Gui, Add, Edit, x+0 y%Status2Y% w38 h16 CBlack vMaxFdIt gGetText, %MaxItems%
Gui, Add, Text,, ;placeholder for the picture preview data-text
Gui, Add, Button, % "x" GuiMargin+245 " y" GuiMargin-35+30 " w112 h26 gButtonDefaultIco", &Set Default
Gui, Add, Button, % "x+5" " y" " w112 h26 gButtonScan", &Scan folders
Gui, Add, Button, % "x+17" " y" " w105 h26 gApplyIcon Default", &Apply Icon
Gui, Add, Button, % "x+5" " y" " w105 h26 gButtonOpen", &Open Folder
Gui, font, s13 bold, Tahoma
Gui, Add, Button, x+5 yp-0 w25 h26 gMenuExit, X
Gui, Add, Text, x0 y0 w%GuiW% h%GuiH% c%GuiColor% Backgroundtrans +0x200 gGuiMove vMOVER
LV_ModifyCol (1, 210) ;100
Gui, Show, h%GuiH% w%GuiW% %GuiX% %GuiY%, %MainWnd%
WinGet, id320, ID, A
If ShowTTip
Control,Check,,Button2,%MainWnd%
ControlFocus, Edit1, %MainWnd%
LastText = fadsfSDFDFasdFdfsadfsadFDSFDf
GoSub, GetText
Control, Choose, 1, SysListView321, %MainWnd%
Return
;______END of AUTOEXECUTE section______________________
ReadIni:
;SplashImage design attribs:
Spl_Design = y30 x800 w150 M C11 ZH0 ZW0 ZX5 ZY5 B1 CT236782 CWffffcc FM7 FS7 WM600 WS400
GoSub, IniGui_Load
Return
WriteIni:
;Creating ini File - if not any
FileAppend,
(LTrim
[Scanning]
PathList=D:\PICs\ICO|E:\PICs\ICO|F:\PICs\ICO|G:\PICs\ICO
;Список сканируемых папок, содержащих файлы значков`n
TypeList=|ico
;Сканируемые расширения`n
ListFile=IcoList.lst
;Наименование файла индекса`n
[Display]
ShowTTip=0
;Всплывающая подсказка`n
ListColor=efefef
;Фоновый цвет списка значков`n
ListTextC=0002CC
;Цвет имён значков`n
GuiColor=E3E3E3
;Цвет фона главного окна`n
MaxFindItems=99999
;Максимальное число результатов поиска`n
MaxItems=42
;Максимальное число значков до начала поиска`n
[Advanced]
OpenFileWith=C:\Program Files\AWicons Pro\AWiconsPro.exe
;Путь к вашему редактору иконок`n
MinLen=2
;Минимальное число символов для начала поиска`n
ShellIntegration=0
;Добавление пункта в контекстное меню всех папок (если откомпилирован).`n
),%IniFile%
Return
ReadScanFile:
IndexFile = %A_ScriptDir%\%ListFile%
ItemList =
FileGetSize, LFSize, %IndexFile%
VarSetCapacity(ItemList,LFSize)
ln =
Loop, Read, %IndexFile%
{
IfEqual, A_LoopReadLine,
Continue
ln ++
ItemList = %ItemList%|%A_LoopReadLine%
}
SetTimer, RemoveTrT, 3000
Return
RemoveTrT:
SetTimer, RemoveTrT, Off
SplashImage, OFF
return
MenuIni:
RunWait, %IniFile%
Reload
Sleep, 1300
Return
MenuExit:
ExitApp
return
CheckScanDate_and_CreateMenus:
FileGetTime, FDDiff, %A_ScriptDir%\%ListFile%, M ; Retrieves the modification time by default.
EnvSub, FDDiff, %A_Now%, minutes
FDDiff := round(FDDiff/60,2) ;in hours
SetTimer, CheckScanDate_and_CreateMenus, % 3 * (60*1000) ;mins
If MenuMade
{
Menu, MyContextMenu, DeleteAll
Menu, Tray, DeleteAll
}
MenuMade = 1
FDDiff_abs := abs(FDDiff)
FDDiff_min := round( (FDDiff_abs - floor(FDDiff_abs)) / 100*60*100, 0)
If (FDDiff_min < 10)
FDDiff_min := "0" . FDDiff_min
FDDiff_time := floor(FDDiff_abs) ":" FDDiff_min
Menu, MyContextMenu, Add, &Apply this icon to folder, ApplyIcon
Menu, MyContextMenu, Add, Open containing folder, ButtonOpen
Menu, MyContextMenu, Add, &Edit Icon, EditIcon
Menu, MyContextMenu, Add
Menu, MyContextMenu, Add, % "Scan folders (last scan " . FDDiff_time . " ago)", ButtonScan
Menu, MyContextMenu, Add, Scan-statistics, ScanStat
Menu, MyContextMenu, Add
Menu, MyContextMenu, Add, Edit settings (ini file), MenuIni
Menu, MyContextMenu, Add
Menu, MyContextMenu, Add, Exit, MenuExit
;Menu, MyContextMenu, Default, Reload this script
Menu, Tray, NoStandard
Menu, Tray, Add, Open Search Window %a_tab%CapsLock+I, Show320
Menu, Tray, Add
Menu, Tray, Add, % "Scan folders (last scan " . FDDiff_time . " ago)", ButtonScan
Menu, Tray, Add, Scan-statistics, ScanStat
Menu, Tray, Add
Menu, Tray, Add, Edit settings (ini file), MenuIni
Menu, Tray, Add
Menu, Tray, Add, Exit, MenuExit
Menu, Tray, Default, Open Search Window %a_tab%CapsLock+I
Return
EditIcon:
SelItem := LV_GetNext()
LV_GetText(0FName, SelItem, 1)
Run, %OpenFileWith% "%0FDir%\%0FName%.%0FExt%"
Return
ScanStat:
mExtList =
Loop, Parse, ItemList, |
{
CurrItem = %A_LoopField%
IfInString,CurrItem,://
FExt := "FF url"
else
SplitPath, CurrItem, FName, FDir, FExt, FNameNoExt, FDrive
mExtList = %mExtList%|%FExt%
}
Sort, mExtList, D|
mExt =
mCn =
aCn = 1
mSg =
Loop, Parse, mExtList, |
{
IfEqual, mExt, %A_LoopField%
{
mCn ++
}
else
{
mSg = %mSg%%mExt%`t%mCn%`n
mExt = %A_LoopField%
mCn = 1
}
aCn ++
}
MsgBox, %mSg%`n`nAll`t%aCn%
mExtList =
Return
GetText:
ControlGetText, MaxItems, Edit2, %MainWnd%
ControlGetText, CurrText, Edit1, %MainWnd%
IfEqual, CurrText, %LastText%, Return
StringLen, Check, CurrText
IfGreater, Check, 0
IfLess, Check, %MinLen%
Return
LastText = %CurrText%
StartTime := A_TickCount
moreth =
;from last used_____________________________
IfEqual, CurrText,
{
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(10, 10, IconSize)
; Attach the ImageLists to the ListView so that it can later display the icons:
LV_SetImageList(ImageListID1)
LV_Delete()
Count =
StringTrimLeft, ItemList0, ItemList, 1
Loop, Parse, ItemList0, |
{
;check for change in search query
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
;Firefox cucc feldolg
CurrItem1 =
CurrItem2 =
;!!StringSplit,CurrItem,A_LoopField,#
If CurrItem2
{
FName = %CurrItem2%
FDir = %CurrItem1%
FNameNoExt = %CurrItem2%
FExt =
}
else
;firefox feldolg vйge
SplitPath, A_LoopField, FName, FDir, FExt, FNameNoExt
Count ++
IfGreater, Count, %MaxItems%, Break
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopField, UShortP, iIndex)
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
DllCall("DestroyIcon", Uint, hIcon)
LV_Add("Icon" Count, FNameNoExt, FExt, FDir )
}
}
;from all items_____________________________
IfNotEqual, CurrText,
{
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(10, 10, IconSize)
; Attach the ImageLists to the ListView so that it can later display the icons:
LV_SetImageList(ImageListID1)
LV_Delete()
;___________________________________________
; Advanced Search
MatchPList1 =
MatchPList2 =
MatchPList3 =
Count = 0
Count2 = 0
ln = 0
GuiControl,, Results, Searching...
Loop, Parse, ItemList, |
{
IfGreater, Count2, %MaxFindItems%, Break
;check for change in search query
If (A_TickCount - StartTime > 1000)
{
ControlGetText, CurrText, Edit1, %MainWnd%
}
IfNotEqual, CurrText, %LastText%, Goto, GetText
CurrItem = %A_LoopField%
;Firefox cucc feldolg
CurrItem1 =
CurrItem2 =
StringSplit,CurrItem,A_LoopField,#
If CurrItem2
{
FName = %CurrItem2%
FDir = %CurrItem1%
FNameNoExt = %CurrItem2%
FExt =
}
else
;firefox feldolg vйge
SplitPath, CurrItem, FName, FDir, FExt, FNameNoExt, FDrive
StringLower,FExt,FExt
;search everywhere or file name only
;fuzzy search
Wht := FName
MatchFound = Y
Loop, Parse, CurrText, %A_Space%
{
StringLeft,opst,A_LoopField,1
IfEqual,opst,-
{
IfEqual,A_LoopField,-dir
{
IfEqual, FExt, lnk
{
FileGetShortcut, %CurrItem%, TargItem
SplitPath, TargItem, TargFName, TargFDir, TargFExt, TargFNameNoExt, TargFDrive
IfNotEqual,TargFExt,
MatchFound = N
}
else
MatchFound = N
}
else
{
StringTrimLeft,Srch,A_LoopField,1
IfInString, Wht, %Srch%
MatchFound = N
}
}
else ;not -excludeword
{
IfNotInString, Wht, %A_LoopField% ;vagy FName helyett CurrItem
MatchFound = N
}
}
IfEqual, MatchFound, Y
{
MatchPList2 = %MatchPList2%|%CurrItem%
Count2 ++
Continue
}
} ;end of loop parse searchlist at line 479
;used only MatchPList2
MatchPList = %MatchPList1%%MatchPList2%%MatchPList3%
StringTrimLeft, MatchPList, MatchPList, 1
Loop, Parse, MatchPList, |
{
;check for change in search query
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
Count ++
IfGreater, Count, %MaxFindItems%
{
moreth := "+"
Break
}
CurrItem = %A_LoopField%
;Firefox cucc feldolg
CurrItem1 =
CurrItem2 =
;!!StringSplit,CurrItem,A_LoopField,#
If CurrItem2
{
FName = %CurrItem2%
FDir = %CurrItem1%
FNameNoExt = %CurrItem2%
FExt =
}
else
;firefox feldolg vйge
SplitPath, A_LoopField, FName, FDir, FExt, FNameNoExt, FDrive
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopField, UShortP, iIndex)
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
DllCall("DestroyIcon", Uint, hIcon)
LV_Add("Icon" Count, FNameNoExt, FExt, FDir )
}
IfEqual, Count,
LV_Delete()
}
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
;post results
Results := LV_GetCount() . moreth
ElapsedTime := (A_TickCount - StartTime)/1000
Fstop := round(ElapsedTime,2)
GuiControl,, Results, %Results% results ;(%Fstop% sec)
LV_ModifyCol()
;select first item
ControlSend, SysListView321, {Down}, %MainWnd%
Return
ButtonScan:
;GoSub, Hide320
Menu, Tray, Icon, Shell32.dll, 57 ;23 57 172 210
FileDelete, %A_ScriptDir%\Scan%ListFile%
;generating file list
IfInString, PathListX, ***
PathListX = C:
Loop, Parse, PathListX, |
{
IfNotExist, %A_LoopField%, Continue
SplashImage,, %Spl_Design%,%A_LoopField%,Scanning folders...
;Skip scanning Favorites if url is not to be indexed
If A_LoopField contains Favorites
If Typelist not contains url,***
Continue
Loop, %A_LoopField%\*.*, 0, 1
{
SplitPath, A_LoopFileFullPath, FName, FDir, FExt, FNameNoExt, FDrive
;only filetypes defined are added
bSupportedExt := FALSE
Loop PARSE, TypeList, |
{
If not A_LoopField
Continue
If (FExt = A_LoopField or A_LoopField = "***")
bSupportedExt := TRUE
}
if (not bSupportedExt)
Continue
;excluding items based on ExcludeList
Cont = 0
Loop, Parse, ExcludeList, |
{
IfInString, A_LoopFileFullPath, %A_LoopField%
{
Cont = 1
Break
}
}
IfEqual, Cont, 1
Continue
;reaching here means that file is not to be excluded and
;has a desired extension
FileAppend, %A_LoopFileFullPath%`n, %A_ScriptDir%\Scan%ListFile%
}
}
ScanItemList =
;--sort by mod-date------------------------------------------------------
SplashImage,, %Spl_Design%,Sorting by mod date,Scanning folders...
Loop, Read, %A_ScriptDir%\Scan%ListFile%
{
IfEqual, A_LoopReadLine,, Continue
SplitPath, A_LoopReadLine, FName, FDir, FExt, FNameNoExt
FPath := A_LoopReadLine
FileGetTime, FMod, %FPath%, M
if (InStr(FExt,"lnk"))
FileGetShortcut, %A_LoopReadLine%, FPath
ScanItemList = %ScanItemList%%FMod%`t%A_LoopReadLine%`n
}
;!!Sort, ScanItemList, R ;Reverse sort
FileDelete, %A_ScriptDir%\Scan%ListFile%
if ERRORLEVEL
{
MsgBox, The Scan_index file could not be deleted: `n%A_ScriptDir%\Scan%ListFile%. `nSorted results are not written back.
;Critical, OFF
Menu, Tray, Icon, Shell32.dll, 23 ;23 57 172 210
Return
}
SplashImage,, %Spl_Design%,Rewriting sorted items,Scanning folders...
Loop, parse, ScanItemList, `n
{
if A_LoopField = ; Omit the last linefeed (blank item) at the end of the list.
continue
StringSplit, FileItem, A_LoopField, %A_Tab% ; Split into two parts at the tab char.
FileAppend, %FileItem2%`n, %A_ScriptDir%\Scan%ListFile%
}
ScanItemList =
Sleep, 1000
RenRetry =
ButtonScan_RenameRetry:
ERRORLEVEL =
FileMove,%A_ScriptDir%\Scan%ListFile%,%A_ScriptDir%\%ListFile%,1
if ERRORLEVEL
{
RenRetry ++
Sleep, 1000
SplashImage,, %Spl_Design%,Retrying %RenRetry% of 10,Scan file rename error...
If (RenRetry < 11)
GoTo, ButtonScan_RenameRetry
SetTimer, RemoveTrT, 100
MsgBox, Scan Error: The Scan_index file could not be renamed.`n%A_ScriptDir%\Scan%ListFile%. `nScanned results are not updated.
;Critical, OFF
Menu, Tray, Icon, Shell32.dll, 23 ;23 57 172 210
Return
}
Sleep, 1000
Menu, Tray, Icon, Shell32.dll, 23 ;23 57 172 210
GoSub, Show320
LastText = xkhdkhsaoihdiiouwoeiue ;refresh
Goto, GetText ;refresh
SplashImage,, %Spl_Design%,Reading in new items,Scanning folders...
GoSub, ReadScanFile
LastText =
SplashImage,, %Spl_Design%,,Scanning ready.
SetTimer, RemoveTrT, 3000
;Critical, OFF
Menu, Tray, Icon, Shell32.dll, 23 ;23 57 172 210
Return
ButtonOpen:
ControlGetFocus, curFoc, %MainWnd%
IfEqual, curFoc, Edit2
{
ControlFocus, Edit1, %MainWnd%
Return
}
Gui, Submit, NoHide
GetKeyState, ShKey, Shift
GetKeyState, CtKey, Control
GetKeyState, WinKey, LWin
ControlFocus, SysListView321, %MainWnd%
;running a found file/folder
IfNotEqual, RunSearch, 1
LV_GetText(FName, SelItem, 1)
LV_GetText(FExt, SelItem, 2)
LV_GetText(FDir, SelItem, 3)
IfEqual, FExt,
IfNotInString,FDir,://
RunItem = %FDir%\%FName%
else
RunItem = %FDir%
IfNotEqual, FExt,
RunItem = %FDir%\%FName%.%FExt%
FileExist = 1
;remove the last \ from a launched folder's name
StringRight, check, RunItem, 1
IfEqual, check, \
StringTrimRight, RunItem, RunItem, 1
;add the \ back if the target is a drive path
StringLen, check, RunItem
IfLess, check, 3
RunItem = %RunItem%\
IfInString,RunItem,://
Add2History = %RunItem%#%FName%
else
Add2History = %RunItem%
SplitPath, RunItem, FName, FDir, FExt, FNameNoExt, FDrive
;shift key down opens host folder
IfEqual, ShKey, D
{
;Run, %OpenFolderWithX% "%FDir%"
GoSub, Hide320
Return
}
Run, Explorer /select`,"%RunItem%",, UseErrorLevel
GoSub, Hide320
Return
;;End ButtonOpen
Selection:
ControlGet, ShowTTip, Checked,, Button2, %MainWnd% ;A ShowTTip checkbox бllapota
GetKeyState, Esckey, Esc
IfEqual, Esckey, D
Return
SelItem := LV_GetNext()
LV_GetText(0FName, SelItem, 1)
LV_GetText(0FExt, SelItem, 2)
LV_GetText(0FDir, SelItem, 3)
IfInString,0FDir,://
Pth = %0FDir% [%0FName%]
else
Pth = %0FDir%\%0FName%.%0FExt%
FTarget =
If Pth
{
if (InStr(0FExt,"lnk"))
{
FileGetShortcut, %Pth%, FTarget
SplitPath, FTarget, mFName, mFDir, mFExt
}
else
SplitPath, Pth, mFName, mFDir, mFExt
If mFExt in gif,png,ico,ani,cur ;Other images in Gui
{
WinMove,%MainWnd%,,%GuiX%,%GuiY%,% GuiW + 260,%GuiH% ;Make Gui bigger
shPng := true
; If shIE
; IE_Move(pwb, GuiW, GuiMargin+40, 0, 0)
GuiControl,, Static3, *w0 *h0 %Pth%
GuiControl,MoveDraw, Static5, % "X" GuiW " Y" GuiMargin+561 " w200 h20"
GuiControlGet, Pic, Pos, Static3
GuiControl,, Static5,Icon preview: (%PicW% x %PicH%)
;The position/size will be stored in PicX, PicY, PicW, and PicH
If (PicW > 256)
GuiControl,, Static3, *w190 *h-1 %Pth%
}
}
if (Pth && ShowTTip)
{
if (InStr(0FExt,"lnk"))
{
FileGetTime, FileDate, %FTarget%, M ; Retrieves the modification time by default.
}
else
{
FileGetTime, FileDate, %Pth%, M ; Retrieves the modification time by default.
}
FormatTime, FileDate, %FileDate%, yyyy.MM.dd HH:mm
ToShow = File:`t%Pth%
If not wH
WinGetPos, wX, wY, wW, wH, %MainWnd%
;ToolTip, %ToShow%, %wW%, 3 ;jobboldalt felьl
ToolTip, %ToShow%, 0, %wH% ;alul
}
IfEqual, A_GuiControlEvent, DoubleClick
GoTo, ButtonOpen
Return
GuiEscape:
GuiClose:
GoSub, Hide320
Return
GuiMove:
Critical
PostMessage, 0xA1, 2,,, A
Sleep, 200
Critical, Off
Return
;Chris made this long ago!
ExpandVars(Var)
{
var_new = %var%
in_reference = n
Loop, parse, var_new, `%
{
if in_reference = n
{
in_reference = y
continue
}
StringTrimLeft, ref_contents, %A_LoopField%, 0
StringReplace, var_new, var_new, `%%A_LoopField%`%, %ref_contents%, all
in_reference = n
}
Return, var_new
}
Hide320:
ControlFocus, SysListView321, %MainWnd% ;removes long name tooltip
If shPng
WinMove,%MainWnd%,,%GuiX%,%GuiY%,%GuiW%,%GuiH%
ControlGetText, zz, Edit1, %MainWnd%
GUI submit, nohide
if Hide320 = 1
{
WinSet, AlwaysOnTop, ON, ahk_id %id320%
}
else
{
if id320 <> -1
{
WinHide, ahk_id %id320%
ToolTip
}
}
ToolTip
Return
Show320:
if id320 <> -1
{
;Reload ListItems
WinShow, ahk_id %id320%
WinActivate, ahk_id %id320%
ControlFocus, Edit1, ahk_id %id320%
GoSub, ReadScanFile
}
if (zz)
ControlSetText,Edit1,%zz%,ahk_id %id320%
Send, ^a ;select all
Return
IniGui_Load:
If (!IniGui_IniFile)
{
MsgBox, IniGui_IniFile is not defined.
Return
}
IfNotExist,%IniGui_IniFile%
{
MsgBox, %IniGui_IniFile% created.
Reload
}
IniGui_Hiba =
Loop, Read, %IniGui_IniFile%
{
If (!A_LoopReadLine or SubStr(A_LoopReadLine,1,1)=";")
Continue
If (SubStr(A_LoopReadLine,1,1)="[")
{
StringReplace,IniGui_Sect,A_LoopReadLine,[,,All
StringReplace,IniGui_Sect,IniGui_Sect,],,All
}
else
{
StringSplit,IniGui_Item,A_LoopReadLine,=
IniGui_Par = %IniGui_Item1%
IniRead,%IniGui_Par%,%IniGui_IniFile%,%IniGui_Sect%,%IniGui_Par%
;MsgBox, IniRead-%IniGui_Item1%-%IniGui_IniFile%-%IniGui_Sect%-%IniGui_Item1%
}
}
Return
GuiContextMenu: ; Launched in response to a right-click or press of the Apps key.
GoSub, CheckScanDate_and_CreateMenus
Menu, MyContextMenu, Show , ;220, 100 ;%A_GuiX%, %A_GuiY%
Return
ApplyIcon:
IfNotEqual, RunSearch, 1
LV_GetText(FName, SelItem, 1)
LV_GetText(FExt, SelItem, 2)
LV_GetText(FDir, SelItem, 3)
GoSub, Hide320
Loop, parse, ClipFolder, `n, `r
{
ClipFolder = %A_LoopField%
FileSetAttrib, -RASH, %ClipFolder%\Yr_Ft_Is*.*, 1
FileDelete, %ClipFolder%\Yr_Ft_Is*.*
Filecopy, %0FDir%\%0FName%.%0FExt%, %ClipFolder%\Yr_Ft_Is*.*
FileSetAttrib, +ASH, %ClipFolder%\Yr_Ft_Is*.*, 1
FileSetAttrib, -RASH, %ClipFolder%\desktop.ini
FileDelete, %ClipFolder%\desktop.ini
FileAppend,
(LTrim
[.ShellClassInfo]
IconFile=Yr_Ft_Is%0FName%.%0FExt%
IconIndex=0
)`n, %ClipFolder%\Desktop.ini
FileSetAttrib, +ASH, %ClipFolder%\Desktop.ini
FileSetAttrib, +S, %ClipFolder%
}
; Если скомпилирован - выйти после замены значка
StringRight, ExtChk, A_ScriptFullPath, 4
IfEqual, ExtChk, .exe
ExitApp
Return
ButtonDefaultIco:
IfNotEqual, RunSearch, 1
LV_GetText(FName, SelItem, 1)
LV_GetText(FExt, SelItem, 2)
LV_GetText(FDir, SelItem, 3)
GoSub, Hide320
Loop, parse, ClipFolder, `n, `r
{
ClipFolder = %A_LoopField%
FileSetAttrib, -RASH, %ClipFolder%\Yr_Ft_Is*.*, 1
FileDelete, %ClipFolder%\Yr_Ft_Is*.*
FileSetAttrib, -RASH, %ClipFolder%\desktop.ini
FileDelete, %ClipFolder%\desktop.ini
FileSetAttrib, -RASH, %ClipFolder%\Desktop.ini
FileSetAttrib, -S, %ClipFolder%
}
Return
FldLst2ClpBrd:
f_ClipSaved := ClipboardAll
Clipboard =
f_ClipWait_Loop()
ClipFolder = %Clipboard%
Clipboard := f_ClipSaved
f_ClipSaved =
Return
CapsLock & sc017:: ;CapsLock + i
IFWinExist, ahk_id %id320%
{
GoSub, Hide320
Return
}
GoSub, FldLst2ClpBrd
DetectHiddenWindows, ON
IFWinExist, ahk_id %id320%
GoSub, Show320
DetectHiddenWindows, OFF
Return
!^sc017:: ;Alt + Ctrl + i
ExitApp
Return
f_ClipWait_Loop()
{
Loop ; скопировать выделенное в буфер (в цикле, если одного раза будет почему-то недостаточно)
{
SendInput, {CTRL DOWN}{sc2E}{CTRL UP} ;c
ClipWait, 1 ; подождать появления содержимого в буфере максимум 1 секунды
if ErrorLevel = 0 ; если ДОЖДАЛИСЬ содержимого в буфере, то...
Break ; закончить цикл
; если содержимого в буфере не дождались
if A_Index = 3 ; если цикл уже выполнился 3 раза, то...
Break ; закончить цикл
}
return
}