Opt('GUIOnEventMode', 1)
Opt('MustDeclareVars', 1)
Opt('TrayIconDebug', 1)
#include <GuiConstantsEx.au3>
#include <GuiImageList.au3>
#Include <GuiListView.au3>
#Include <WinAPI.au3>
#include <WindowsConstants.au3>
HotKeySet('!{ESC}', '_Pro_Exit'); Alt+ESC - закрыть скрипт
Global Const $WM_DROPFILES = 0x0233
Global Const $sKey = 'HKEY_CURRENT_USER\Software\Drag Helper'
Global $hMainWin, $hFullPath, $hSavePos, $hSaveSize, $hList
Local $hImage
Global $fFullPath = RegRead($sKey, 'Full path')
Global $fSavePos = RegRead($sKey, 'Save pos')
Global $fSaveSize = RegRead($sKey, 'Save size')
Local $iWidth = RegRead($sKey, 'Width')
Local $iHeight = RegRead($sKey, 'Height')
Local $iX = RegRead($sKey, 'X')
Local $iY = RegRead($sKey, 'Y')
If $fFullPath == '' Then
$fFullPath = 0
RegWrite($sKey, 'Full path', 'REG_DWORD', $fFullPath)
EndIf
If $fSavePos == '' Then
$fSavePos = 1
RegWrite($sKey, 'Save pos', 'REG_DWORD', $fSavePos)
EndIf
If $fSaveSize == '' Then
$fSaveSize = 1
RegWrite($sKey, 'Save size', 'REG_DWORD', $fSaveSize)
EndIf
If $iWidth == '' OR $iWidth < 265 Then
$iWidth = 265
RegWrite($sKey, 'Width', 'REG_DWORD', $iWidth)
EndIf
If $iHeight == '' OR $iHeight < 220 Then
$iHeight = 220
RegWrite($sKey, 'Height', 'REG_DWORD', $iHeight)
EndIf
If $iX == '' Then
$iX = 100
RegWrite($sKey, 'X', 'REG_DWORD', $iX)
EndIf
If $iY == '' Then
$iY = 100
RegWrite($sKey, 'Y', 'REG_DWORD', $iY)
EndIf
$hMainWin = GUICreate('Drag Helper', $iWidth, $iHeight, $iX, $iY, $WS_OVERLAPPEDWINDOW, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST))
GUISetOnEvent($GUI_EVENT_CLOSE, '_Pro_Exit')
GUICtrlCreateButton('Clear', 206, 10, 50, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetOnEvent(-1, '_Clear')
$hFullPath = GUICtrlCreateCheckbox('Показывать полный адрес папок', 10, 10, 195, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
If $fFullPath Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetOnEvent(-1, '_FullPath')
$hSavePos = GUICtrlCreateCheckbox('Сохранять позицию', 10, 30, 120, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
If $fSavePos Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetOnEvent(-1, '_SavePos')
$hSaveSize = GUICtrlCreateCheckbox('Сохранять размер', 142, 30, 115, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
If $fSaveSize Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetOnEvent(-1, '_SaveSize')
$hList = GUICtrlCreateListView('Результаты обработки', 10, 55, $iWidth-20, $iHeight-65)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
_GUICtrlListView_SetColumnWidth($hList, 0, 800)
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hList, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hList, 0x00FF00, 16, 16))
_GUICtrlListView_SetImageList($hList, $hImage, 1)
GUICtrlSetState($hList, $GUI_FOCUS)
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES')
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUISetState()
Func WM_DROPFILES($hWnd, $msg, $wParam, $lParam)
Local $tBuffer = DllStructCreate('char[256]')
Local $iString, $sDir, $sDirTo, $hSearch, $sFile
Local $aRet = DllCall('shell32.dll', 'int', 'DragQueryFile', 'int', $wParam, 'int', -1, 'ptr', 0, 'int', 0)
;~ If $aRet[0] > 0 Then _GUICtrlListView_DeleteAllItems($hList)
For $i = 0 To $aRet[0] - 1
DllCall('shell32.dll', 'int', 'DragQueryFile', 'int', $wParam, 'int', $i, 'ptr', DllStructGetPtr($tBuffer), 'int', DllStructGetSize($tBuffer))
$sDir = DllStructGetData($tBuffer, 1)
If StringInStr(FileGetAttrib($sDir), 'D') Then
$hSearch = FileFindFirstFile($sDir & '\*.*')
If @error == -1 Then ContinueLoop
Dim $iFile1 = 0, $iFile2 = 0, $iFile3 = 0
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
$sFile = StringRegExpReplace($sFile, '.*\.(.+)$', '\1')
Switch $sFile
Case 'cue'
$iFile1 += 1
Case 'ape'
$iFile2 += 1
Case 'flac'
$iFile2 += 1
Case 'wv'
$iFile2 += 1
Case Else
$iFile3 += 1
EndSwitch
WEnd
FileClose($hSearch)
If $iFile1 == 1 AND $iFile2 == 1 AND $iFile3 == 0 Then
$iFile1 = 1
Else
$sDirTo = StringRegExpReplace($sDir, '(.+\\)(.+)$', '\1' & '_\2')
DirMove($sDir, $sDirTo)
$sDir = $sDirTo
$iFile1 = 0
EndIf
If NOT $fFullPath Then $sDir = StringRegExpReplace($sDir, '.+\\(.+)$', '\1')
GUICtrlCreateListViewItem(' ' & $sDir, $hList)
_GUICtrlListView_SetItemImage($hList, _GUICtrlListView_GetItemCount($hList)-1, $iFile1)
EndIf
Next
DllCall('shell32.dll', 'none', 'DragFinish', 'int', $wParam)
Return $GUI_RUNDEFMSG
EndFunc
Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
Local $iProc = DllCall('user32.dll', 'int', 'DefWindowProc', 'hwnd', $hWnd, 'int', $Msg, 'wparam', $wParam, 'lparam', $lParam)
If $iProc[0] = $HTCLIENT Then Return $HTCAPTION
Return $GUI_RUNDEFMSG
EndFunc
Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)
If NOT $fSavePos OR BitAnd(WinGetState($hMainWin), 16) OR BitAnd(WinGetState($hMainWin), 32) Then Return
Local $aWinPos = WinGetPos($hMainWin)
RegWrite($sKey, 'X', 'REG_DWORD', $aWinPos[0])
RegWrite($sKey, 'Y', 'REG_DWORD', $aWinPos[1])
EndFunc
Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
If NOT $fSaveSize OR BitAnd(WinGetState($hMainWin), 16) OR BitAnd(WinGetState($hMainWin), 32) Then Return
RegWrite($sKey, 'Width', 'REG_DWORD', _WinAPI_LoWord($lParam))
RegWrite($sKey, 'Height', 'REG_DWORD', _WinAPI_HiWord($lParam))
EndFunc
Func _FullPath()
$fFullPath = BitAND(1, GUICtrlRead($hFullPath))
RegWrite($sKey, 'Full path', 'REG_DWORD', $fFullPath)
EndFunc
Func _SavePos()
$fSavePos = BitAND(1, GUICtrlRead($hSavePos))
RegWrite($sKey, 'Save pos', 'REG_DWORD', $fSavePos)
EndFunc
Func _SaveSize()
$fSaveSize = BitAND(1, GUICtrlRead($hSaveSize))
RegWrite($sKey, 'Save size', 'REG_DWORD', $fSaveSize)
EndFunc
Func _Clear()
_GUICtrlListView_DeleteAllItems($hList)
EndFunc
While 1
Sleep(10)
WEnd
Func _Pro_Exit()
Exit
EndFunc