Advertisement
AZJIO

Эксплорер как бы

Oct 23rd, 2011
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 20.27 KB | None | 0 0
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Outfile=File_manager.exe
  3. #AutoIt3Wrapper_Icon=File_manager.ico
  4. #AutoIt3Wrapper_Compression=4
  5. #AutoIt3Wrapper_Res_Comment=-
  6. #AutoIt3Wrapper_Res_Description=File_manager.exe
  7. #AutoIt3Wrapper_Res_Fileversion=0.3.0.0
  8. #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=n
  9. #AutoIt3Wrapper_Res_LegalCopyright=AZJIO
  10. #AutoIt3Wrapper_Res_Language=1049
  11. #AutoIt3Wrapper_Run_Au3check=n
  12. #AutoIt3Wrapper_Res_Field=Version|0.3
  13. #AutoIt3Wrapper_Res_Field=Build|2013.11.12
  14. #AutoIt3Wrapper_Res_Field=Coded by|AZJIO
  15. #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
  16. #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
  17. #AutoIt3Wrapper_Run_Obfuscator=y
  18. #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
  19. #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
  20. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  21.  
  22. #include <GUIConstantsEx.au3>
  23. #include <GuiTreeView.au3>
  24. #include <WindowsConstants.au3>
  25. ; #include <GuiImageList.au3>
  26. #include <File.au3>
  27. #include <GuiListView.au3>
  28. #include <GuiStatusBar.au3>
  29. #include <FileOperations.au3>
  30. ; #Include <Array.au3> ; тест
  31.  
  32. Opt("GUIOnEventMode", 1)
  33.  
  34. Global $PathCur, $TrWM_NOTIFY = 0
  35.  
  36. ; En
  37. $LngTitle = 'File manager'
  38. $LngJmp = 'Go'
  39. $LngTmAs = 'Access time :'
  40. $LngSec = 'sec'
  41. $LngBS = 'Up'
  42. ; $LngCpP = 'Copy path'
  43. ; $LngDel = 'Delete'
  44.  
  45. $UserIntLang = @OSLang
  46.  
  47. ; Ru
  48. ; если русская локализация, то русский язык
  49. If $UserIntLang = 0419 Then
  50.     $LngTitle = 'Файловый менеджер'
  51.     $LngJmp = 'Перейти'
  52.     $LngTmAs = 'Время доступа :'
  53.     $LngSec = 'сек'
  54.     $LngBS = 'Вверх'
  55.     ; $LngCpP = 'Копировать путь'
  56.     ; $LngDel = 'Удалить'
  57. EndIf
  58.  
  59. $hGui = GUICreate($LngTitle, 640, 560, -1, -1, $WS_OVERLAPPEDWINDOW)
  60. GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
  61. Local $aParts[3] = [640 - 210, -1]
  62. $hStatusBar = _GUICtrlStatusBar_Create($hGui, $aParts, '', $SBARS_TOOLTIPS + $SBARS_SIZEGRIP)
  63.  
  64. $restart = GUICtrlCreateButton("R", 640 - 20, 2, 18, 20)
  65. GUICtrlSetResizing(-1, 512 + 256 + 32 + 4)
  66. GUICtrlSetOnEvent(-1, "_restart")
  67.  
  68. $iBS = GUICtrlCreateButton("^", 5, 6, 24, 24)
  69. GUICtrlSetResizing(-1, 2 + 32 + 256 + 512)
  70. GUICtrlSetOnEvent(-1, "_ActionBS")
  71. GUICtrlSetTip(-1, $LngBS)
  72.  
  73. $Address = GUICtrlCreateInput('', 32, 6, 540, 24)
  74. GUICtrlSetResizing(-1, 2 + 4 + 32 + 512)
  75. $go = GUICtrlCreateButton(">", 577, 6, 24, 24)
  76. GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
  77. GUICtrlSetOnEvent(-1, "_Jump")
  78. GUICtrlSetTip(-1, $LngJmp)
  79.  
  80. $iTreeView = GUICtrlCreateTreeView(0, 35, 216, 500, -1, $WS_EX_CLIENTEDGE)
  81. GUICtrlSetResizing(-1, 2 + 32 + 64 + 256)
  82. $hTreeView = GUICtrlGetHandle($iTreeView)
  83.  
  84. $hImage = _GUIImageList_Create(16, 16, 5, 1)
  85. _GUIImageList_AddIcon($hImage, @SystemDir & '\shell32.dll', -4)
  86. ; _GUIImageList_AddIcon($hImage, @SystemDir & '\shell32.dll', -5)
  87. ; _GUIImageList_AddIcon($hImage, @SystemDir & '\shell32.dll', 0)
  88. _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)
  89.  
  90. $DrivesArr = DriveGetDrive("all")
  91. For $i = 1 To $DrivesArr[0]
  92.     If $DrivesArr[$i] = 'a:' Or DriveGetType($DrivesArr[$i] & '\') = 'CDROM' Then ContinueLoop
  93.     $hTmp = _GUICtrlTreeView_Add($hTreeView, 0, StringUpper($DrivesArr[$i]), 0, 0)
  94.     _GUICtrlTreeView_SetChildren($hTreeView, $hTmp) ; добавляем плюсик
  95. Next
  96.  
  97. $iListView = GUICtrlCreateListView(' ', 220, 35, 420, 500, $LVS_NOCOLUMNHEADER + $LVS_SHOWSELALWAYS, BitOR($LVS_EX_INFOTIP, $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT))
  98. ; GUICtrlSendMsg($iListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
  99. GUICtrlSetBkColor(-1, 0xf0f0f0) ; 0xE0DFE3
  100. GUICtrlSetResizing(-1, 2 + 4 + 32 + 64)
  101. $hListView = GUICtrlGetHandle($iListView)
  102. _GUICtrlListView_SetColumnWidth($iListView, 0, 390)
  103.  
  104. Local $g_aExtAssot[1] = [0] ; Белый список ассоциаций
  105. Local $g_aExtBlack[6] = [5, 'exe', 'scr', 'ico', 'ani', 'cur'] ; Чёрный список ассоциаций
  106. $g_hImgAssot = _GUIImageList_Create(16, 16, 5, 1)
  107. _GUICtrlListView_SetImageList($iListView, $g_hImgAssot, 1)
  108. ; _GUICtrlTreeView_SetNormalImageList($hTreeView, $g_hImgAssot)
  109. _GUIImageList_AddIcon($g_hImgAssot, @SystemDir & '\shell32.dll', -4)
  110. ; _GUIImageList_AddIcon($g_hImgAssot, @SystemDir & '\shell32.dll', -5)
  111. For $i = 1 To 10
  112.     _GUIImageList_AddIcon($g_hImgAssot, @SystemDir & '\shell32.dll', 0) ; Делаем кэш 9 иконок для EXE-файлов. В папке первые 9 EXE-файлов будут отображаться своими иконками, а если более 9, то остальные будут пустышками отображаться. надеюсь 9 достаточно.
  113. Next
  114.  
  115. $ReLbl = GUICtrlCreateLabel('', 216, 35, 5, 500)
  116. GUICtrlSetResizing(-1, 2 + 32 + 64 + 256)
  117. GUICtrlSetCursor(-1, 13)
  118. GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_ResizeField")
  119.  
  120. $iDummyEnter = GUICtrlCreateDummy()
  121. GUICtrlSetOnEvent(-1, "_ActionEnter")
  122. Local $AccelKeys[1][2] = [["{Enter}", $iDummyEnter]] ; , ["{Backspace}", $iBS] ; Задейстование Backspace запрещает редактирование в адресной строке
  123. GUISetAccelerators($AccelKeys)
  124.  
  125. ; GUICtrlSetOnEvent(-1, "_OpenExplorer")
  126. GUISetState()
  127. GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
  128. GUIRegisterMsg($WM_SIZE, "WM_SIZE")
  129. GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
  130.  
  131. ; перейти к нужной папке
  132. ; $StartPath='C:\AutoIt3\Notepad++'
  133. ; GUICtrlSetData($Address, $StartPath)
  134. ; _Jump()
  135.  
  136. While 1
  137.     Sleep(100000)
  138. WEnd
  139.  
  140. Func _Exit()
  141.     Exit
  142. EndFunc   ;==>_Exit
  143.  
  144. Func _ActionBS()
  145.     ; Switch ControlGetFocus($hGui)
  146.         ; Case 'SysTreeView321', 'SysListView321', 'Button2'
  147.             ; Local $tmp = StringRegExpReplace($PathCur, '(\\[^\\]+)$', '')
  148.             ; If @extended Then _Jump1($tmp)
  149.     ; EndSwitch
  150.     ; Local $tmp = StringRegExpReplace($PathCur, '(\\[^\\]+)$', '')
  151.     ; If @extended Then _Jump1($tmp)
  152.    
  153.     ; GUICtrlSetState($iTreeView, $GUI_FOCUS)
  154.     ; ControlFocus($hGui, "", $iTreeView)
  155.     $hItem = _GUICtrlTreeView_GetSelection($hTreeView) ; получает дескриптор
  156.     $hItem = _GUICtrlTreeView_GetParentHandle($hTreeView, $hItem)
  157.     If $hItem Then _GUICtrlTreeView_ClickItem($hTreeView, $hItem)
  158. EndFunc
  159.  
  160. Func _ActionEnter()
  161.     Switch ControlGetFocus($hGui)
  162.         Case 'Edit1'
  163.             _Jump()
  164.         Case 'SysTreeView321'
  165.             $hItem = _GUICtrlTreeView_GetSelection($hTreeView) ; получает дескриптор
  166.             $sPath = _GetPathItem($hTreeView, $hItem) ; Получили текущий уже открытый
  167.             _Jump1($sPath)
  168.         Case 'SysListView321'
  169.             _GUICtrlListView_ClickItem($hListView, _GUICtrlListView_GetSelectedIndices($hListView), "left", False, 2)
  170.             GUICtrlSetState($iListView, $GUI_FOCUS)
  171.     EndSwitch
  172. EndFunc   ;==>_ActionEnter
  173.  
  174. Func _Jump()
  175.     Local $sKey = GUICtrlRead($Address)
  176.     _Jump1($sKey)
  177. EndFunc   ;==>_Jump
  178.  
  179. Func _Jump1($sKey)
  180.     Local $aKey, $hItem, $i, $j, $key, $KeyChild, $sKey2, $sPath, $aPath, $q = 1, $tmp
  181.     If Not FileExists($sKey) Then Return
  182.  
  183.     $hItem = _GUICtrlTreeView_GetSelection($hTreeView) ; получает дескриптор
  184.     $sPath = _GetPathItem($hTreeView, $hItem) ; Получили текущий уже открытый
  185.  
  186.     ; Проверить, является ли установочный путь частью уже открытого пути
  187.     $aKey = StringSplit($sKey, '\')
  188.     $sKey = $aKey[1]
  189.     $sKey2 = $aKey[1]
  190.  
  191.     If $sPath Then
  192.         $aPath = StringSplit($sPath, '\')
  193.         If $aPath[0] < $aKey[0] Then ; Берётся минимальный размер массива, чтобы не было сбоя при попытке обратиться к меньшему массиву используя конечный индекс большего массива.
  194.             $tmp = $aPath[0]
  195.         Else
  196.             $tmp = $aKey[0]
  197.         EndIf
  198.  
  199.         ; Вычисление начала отсчёта
  200.         For $i = 1 To $tmp
  201.             If $aPath[$i] <> $aKey[$i] Then ExitLoop
  202.             If $i = 1 Then ContinueLoop
  203.             $q += 1
  204.             $sKey &= '|' & $aKey[$i]
  205.             $sKey2 &= '\' & $aKey[$i]
  206.         Next
  207.     EndIf
  208.     ; MsgBox(0, $i, $sKey & @LF & $sKey2 & @LF & $q & @LF & $aKey[0])
  209.  
  210.     For $i = $q To $aKey[0]
  211.         If $i > $q Then
  212.             $sKey &= '|' & $aKey[$i]
  213.             $sKey2 &= '\' & $aKey[$i]
  214.         EndIf
  215.        
  216.         ControlTreeView($hGui, "", $hTreeView, "Select", $sKey) ; выделяет раздел
  217.         If @error Then
  218.             If $i = $q Then
  219.                 Return
  220.             Else
  221.                 ExitLoop
  222.             EndIf
  223.         EndIf
  224.         $hItem = _GUICtrlTreeView_GetSelection($hTreeView) ; получает дескриптор
  225.  
  226.         If _GUICtrlTreeView_GetChildren($hTreeView, $hItem) And Not _GUICtrlTreeView_ExpandedOnce($hTreeView, $hItem) Then
  227.             $tmp = _FileListToArray($sKey2, "*", 2)
  228.             If @error Then Return
  229.             For $j = 1 To $tmp[0]
  230.                 $tmp1 = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $tmp[$j], 0, 0)
  231.                 $search = FileFindFirstFile($sKey2 & '\' & $tmp[$j] & '\*')
  232.                 If $search <> -1 Then
  233.                     While 1
  234.                         $file = FileFindNextFile($search)
  235.                         If @error Then ExitLoop
  236.                         If @extended Then
  237.                             _GUICtrlTreeView_SetChildren($hTreeView, $tmp1) ; добавляем плюсик
  238.                             ExitLoop
  239.                         EndIf
  240.                     WEnd
  241.                 EndIf
  242.                 $tmp1 = ''
  243.                 FileClose($search)
  244.             Next
  245.         EndIf
  246.         _GUICtrlTreeView_Expand($hTreeView, $hItem) ; разворачивает пункт
  247.     Next
  248.     _GUICtrlTreeView_ClickItem($hTreeView, $hItem, "left", False)
  249. EndFunc   ;==>_Jump1
  250.  
  251. Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
  252.     _GUICtrlStatusBar_Resize($hStatusBar)
  253.     Local $aParts[3] = [BitAND($ilParam, 0xFFFF) - 210, -1]
  254.     _GUICtrlStatusBar_SetParts($hStatusBar, $aParts)
  255.     Return $GUI_RUNDEFMSG
  256. EndFunc   ;==>WM_SIZE
  257.  
  258. Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
  259.     Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tmp, $TrWM_NOTIFY = 1
  260.  
  261.     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
  262.     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  263.     $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
  264.     $iCode = DllStructGetData($tNMHDR, "Code")
  265.     Switch $hWndFrom
  266.         Case $hTreeView
  267.             Switch $iCode
  268.                 Case $NM_CLICK
  269.                     ; получение хэндла кликнутого пункта и поиск его в массиве
  270.                     Local $tMPos = _WinAPI_GetMousePos(True, $hWndFrom), $tHit = _GUICtrlTreeView_HitTestEx($hWndFrom, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2))
  271.                     Local $hItem = DllStructGetData($tHit, "Item")
  272.                     If $hItem > 0 Then
  273.                         $tmp = _GetPathItem($hWndFrom, $hItem)
  274.                         If $PathCur = $tmp Then
  275.                             Return
  276.                         Else
  277.                             $PathCur = $tmp
  278.                         EndIf
  279.                         GUICtrlSetData($Address, $PathCur)
  280.                        
  281.                         $timer = TimerInit()
  282.                         _ListView_Update()
  283.                        
  284.                         If _GUICtrlTreeView_GetChildren($hWndFrom, $hItem) And Not _GUICtrlTreeView_ExpandedOnce($hWndFrom, $hItem) Then
  285.                             $tmp = _FileListToArray($PathCur, "*", 2)
  286.                             If @error Then Return
  287.                             ; _GUICtrlTreeView_BeginUpdate($hWndFrom)
  288.                             For $i = 1 To $tmp[0]
  289.                                 $tmp1 = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $tmp[$i], 0, 0)
  290.                                 $search = FileFindFirstFile($PathCur & '\' & $tmp[$i] & '\*')
  291.                                 If $search <> -1 Then
  292.                                     While 1
  293.                                         $file = FileFindNextFile($search)
  294.                                         If @error Then ExitLoop
  295.                                         If @extended Then
  296.                                             _GUICtrlTreeView_SetChildren($hWndFrom, $tmp1) ; добавляем плюсик
  297.                                             ExitLoop
  298.                                         EndIf
  299.                                     WEnd
  300.                                 EndIf
  301.                                 $tmp1 = ''
  302.                                 FileClose($search)
  303.                             Next
  304.                             ; _GUICtrlTreeView_EndUpdate($hWndFrom)
  305.                         EndIf
  306.                         _GUICtrlStatusBar_SetText($hStatusBar, $PathCur)
  307.                         _GUICtrlStatusBar_SetTipText($hStatusBar, 0, $PathCur)
  308.                         _GUICtrlStatusBar_SetText($hStatusBar, $LngTmAs & ' ' & Round(TimerDiff($timer) / 1000, 2) & ' ' & $LngSec, 2)
  309.                     Else
  310.                         Return
  311.                     EndIf
  312.                     GUICtrlSendMsg($iListView, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)
  313.                     GUICtrlSendMsg($iListView, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE_USEHEADER)
  314.                     ; Case $TVN_SINGLEEXPAND
  315.                     ; MsgBox(0, 'Message', '---')
  316.  
  317.                     ; Case $NM_RCLICK
  318.                     ; Local $tMPos = _WinAPI_GetMousePos(True, $hWndFrom), $tHit = _GUICtrlTreeView_HitTestEx($hWndFrom, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2))
  319.                     ; Local $hItem = DllStructGetData($tHit, "Item")
  320.                     ; If $hItem <> -1 And $hItem<>0x0 Then
  321.                     ; MsgBox(0, 'Message', '---')
  322.                     ; $x = MouseGetPos(0)
  323.                     ; $y = MouseGetPos(1)
  324.                     ; DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hGui, "ptr", 0)
  325.                     ; Else
  326.                     ; Return
  327.                     ; EndIf
  328.             EndSwitch
  329.         Case $hListView
  330.             Switch $iCode
  331.                 Case $NM_DBLCLK
  332.                     $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
  333.                     $iItem = DllStructGetData($tInfo, 'Index')
  334.                     If $iItem > -1 Then
  335.                         $tmp = $PathCur & '\' & _GUICtrlListView_GetItemText($hListView, $iItem)
  336.                         If FileExists($tmp) Then
  337.                             If _FO_IsDir($tmp) Then
  338.                                 $timer = TimerInit()
  339.                                 _Jump1($tmp)
  340.                                 $PathCur = $tmp
  341.                                 $timer = TimerInit()
  342.                                 _ListView_Update()
  343.  
  344.                                 GUICtrlSetData($Address, $PathCur)
  345.                                 _GUICtrlStatusBar_SetText($hStatusBar, $PathCur)
  346.                                 _GUICtrlStatusBar_SetTipText($hStatusBar, 0, $PathCur)
  347.                                 _GUICtrlStatusBar_SetText($hStatusBar, $LngTmAs & ' ' & Round(TimerDiff($timer) / 1000, 2) & ' ' & $LngSec, 2)
  348.                             Else
  349.                                 ShellExecute('"' & $tmp & '"')
  350.                             EndIf
  351.                         EndIf
  352.                     EndIf
  353.             EndSwitch
  354.     EndSwitch
  355.     $TrWM_NOTIFY = 0
  356.     Return $GUI_RUNDEFMSG
  357. EndFunc   ;==>WM_NOTIFY
  358.  
  359. Func _ListView_Update()
  360.     _GUICtrlListView_BeginUpdate($hListView)
  361.     _GUICtrlListView_DeleteAllItems($hListView)
  362.    
  363.     $tmp = _FileListToArray($PathCur, "*", 2)
  364.     If Not @error Then
  365.         _AddItem($tmp, $PathCur, 1)
  366.     EndIf
  367.     $tmp = _FileListToArray($PathCur, "*", 1)
  368.     If Not @error Then
  369.         _AddItem($tmp, $PathCur)
  370.     EndIf
  371.     _GUICtrlListView_EndUpdate($hListView)
  372. EndFunc   ;==>_ListView_Update
  373.  
  374. Func _AddItem(ByRef $aFileList, $sPath, $fld = 0)
  375.     Local $ext, $iExeNum = 0, $ind
  376.     For $i = 1 To $aFileList[0]
  377.         If $fld Then
  378.             _GUICtrlListView_AddItem($hListView, $aFileList[$i], 0)
  379.         Else
  380.             $ext = StringRegExpReplace($aFileList[$i], '.*\.(\S+)', '\1')
  381.             If $ext = 'exe' Or $ext = 'ico' Then
  382.                 $iExeNum += 1
  383.                 If $iExeNum < 10 Then
  384.                     _ReplaceIcon($g_hImgAssot, $sPath & '\' & $aFileList[$i], $iExeNum)
  385.                     $ind = $iExeNum - 10
  386.                 Else
  387.                     $ind = 0
  388.                 EndIf
  389.             Else
  390.                 $ind = _Get_Num_ICO($ext)
  391.                 If @error Then $ind = 0
  392.             EndIf
  393.             _GUICtrlListView_AddItem($hListView, $aFileList[$i], $ind + 10)
  394.         EndIf
  395.     Next
  396. EndFunc   ;==>_AddItem
  397.  
  398. Func _ReplaceIcon($hWnd, $sFile, $iIndex = 2)
  399.     Local $pIcon, $tIcon, $hIcon
  400.     $tIcon = DllStructCreate("int Icon")
  401.     $pIcon = DllStructGetPtr($tIcon)
  402.     _WinAPI_ExtractIconEx($sFile, 0, 0, $pIcon, 1) ; извлекает иконку из файла
  403.     $hIcon = DllStructGetData($tIcon, "Icon")
  404.     _GUIImageList_ReplaceIcon($hWnd, $iIndex, $hIcon) ; -1 означает добавление иконки в конец списка, вместо замены
  405.     _WinAPI_DestroyIcon($hIcon)
  406. EndFunc   ;==>_ReplaceIcon
  407.  
  408. Func _CreateItem($hWndFrom, $h, $Path)
  409.     $text = _GUICtrlTreeView_GetText($hWndFrom, $h)
  410.     $tmp = _FileListToArray($Path & '\' & $text, "*", 2)
  411.     If @error Then Return
  412.     For $i = 1 To $tmp[0]
  413.         _GUICtrlTreeView_AddChild($hTreeView, $h, $tmp[$i], 0, 0)
  414.     Next
  415. EndFunc   ;==>_CreateItem
  416.  
  417. Func _GetPathItem($hTreeView, $hItem)
  418.     Local $sep = Opt("GUIDataSeparatorChar", "\")
  419.     Local $sPath = _GUICtrlTreeView_GetTree($hTreeView, $hItem)
  420.     Opt("GUIDataSeparatorChar", $sep)
  421.     Return $sPath
  422. EndFunc   ;==>_GetPathItem
  423.  
  424. Func _restart()
  425.     Local $sAutoIt_File = @TempDir & "\~Au3_ScriptRestart_TempFile.au3"
  426.     Local $sRunLine, $sScript_Content, $hFile
  427.  
  428.     $sRunLine = @ScriptFullPath
  429.     If Not @Compiled Then $sRunLine = @AutoItExe & ' /AutoIt3ExecuteScript ""' & $sRunLine & '""'
  430.     If $CmdLine[0] > 0 Then $sRunLine &= ' ' & $CmdLineRaw
  431.  
  432.     $sScript_Content &= '#NoTrayIcon' & @CRLF & _
  433.             'While ProcessExists(' & @AutoItPID & ')' & @CRLF & _
  434.             '   Sleep(10)' & @CRLF & _
  435.             'WEnd' & @CRLF & _
  436.             'Run("' & $sRunLine & '")' & @CRLF & _
  437.             'FileDelete(@ScriptFullPath)' & @CRLF
  438.  
  439.     $hFile = FileOpen($sAutoIt_File, 2)
  440.     FileWrite($hFile, $sScript_Content)
  441.     FileClose($hFile)
  442.  
  443.     Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sAutoIt_File & '"', @ScriptDir, @SW_HIDE)
  444.     Sleep(1000)
  445.     Exit
  446. EndFunc   ;==>_restart
  447.  
  448. Func _FileDefaultIcon($sExt)
  449.     If $sExt = '' Or StringInStr($sExt, ':') Then Return SetError(1)
  450.  
  451.     Local $aCall = DllCall("shlwapi.dll", "int", "AssocQueryStringW", _
  452.             "dword", 0x00000040, _ ;$ASSOCF_VERIFY
  453.             "dword", 15, _ ;$ASSOCSTR_DEFAULTICON
  454.             "wstr", $sExt, _
  455.             "ptr", 0, _
  456.             "wstr", "", _
  457.             "dword*", 65536)
  458.  
  459.     If @error Then Return SetError(1, 0, "")
  460.  
  461.     If Not $aCall[0] Then
  462.         $sExt = StringReplace($aCall[5], '"', '')
  463.         $sExt = StringSplit($sExt, ',')
  464.         Opt('ExpandEnvStrings', 1)
  465.         $sExt[1] = $sExt[1]
  466.         Opt('ExpandEnvStrings', 0)
  467.         Return SetError(0, 0, $sExt)
  468.     ElseIf $aCall[0] = 0x80070002 Then
  469.         Return SetError(1, 0, "{unknown}")
  470.     ElseIf $aCall[0] = 0x80004005 Then
  471.         Return SetError(1, 0, "{fail}")
  472.     Else
  473.         Return SetError(2, $aCall[0], "")
  474.     EndIf
  475.  
  476. EndFunc   ;==>_FileDefaultIcon
  477.  
  478. Func _ResizeField()
  479.     Local $aClientSize, $aCur_Info, $aID_Pos, $dX, $tmp
  480.     $aCur_Info = GUIGetCursorInfo($hGui)
  481.     If $aCur_Info[4] = $ReLbl Then
  482.         $aID_Pos = ControlGetPos($hGui, '', $ReLbl)
  483.         $aClientSize = WinGetClientSize($hGui)
  484.         $aClientSize[1] -= 60
  485.  
  486.         ; высчитываем разницу координат
  487.         $dX = $aID_Pos[0] - $aCur_Info[0]
  488.         While 1
  489.             Sleep(10)
  490.             $aCur_Info = GUIGetCursorInfo($hGui) ; получаем новую инфу
  491.             $aCur_Info[0] += $dX
  492.            
  493.             If Not ($aCur_Info[0] < 60 Or $aClientSize[0] - $aCur_Info[0] < 60 Or $tmp = $aCur_Info[0]) Then
  494.                 GUICtrlSetPos($ReLbl, $aCur_Info[0], 35) ; устанавливаем новые координаты
  495.                 GUICtrlSetPos($iTreeView, 0, 35, $aCur_Info[0], $aClientSize[1])
  496.                 GUICtrlSetPos($iListView, $aCur_Info[0] + 4, 35, $aClientSize[0] - $aCur_Info[0] - 4, $aClientSize[1])
  497.                 $tmp = $aCur_Info[0]
  498.             EndIf
  499.             If Not $aCur_Info[2] Then ExitLoop ; выход если курсор отпущен
  500.         WEnd
  501.     EndIf
  502. EndFunc   ;==>_ResizeField
  503.  
  504. Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
  505.     #forceref $iMsg, $wParam
  506.     If $hWnd = $hGui Then
  507.         Local $tMINMAXINFO = DllStructCreate("int;int;" & _
  508.                 "int MaxSizeX; int MaxSizeY;" & _
  509.                 "int MaxPositionX;int MaxPositionY;" & _
  510.                 "int MinTrackSizeX; int MinTrackSizeY;" & _
  511.                 "int MaxTrackSizeX; int MaxTrackSizeY", _
  512.                 $lParam)
  513.         DllStructSetData($tMINMAXINFO, "MinTrackSizeX", 350)
  514.         DllStructSetData($tMINMAXINFO, "MinTrackSizeY", 250)
  515.     EndIf
  516. EndFunc   ;==>WM_GETMINMAXINFO
  517.  
  518. Func _Get_Num_ICO($sExt)
  519.     ; Global $g_hImgAssot
  520.     ; Global $g_aExtAssot
  521.     Local $ind, $ico1
  522.     $ind = _ArraySearch2($g_aExtAssot, $sExt)
  523.     If @error Then
  524.         $ico1 = _FileDefaultIcon('.' & $sExt)
  525.         If Not @error Then
  526.             Switch UBound($ico1)
  527.                 Case 2
  528.                     If _ArraySearch2($g_aExtBlack, $sExt) > 0 Then ; Если в чёрном списке, тогда ошибка
  529.                         Return SetError(1, 0, -1)
  530.                     Else
  531.                         _GUIImageList_AddIcon($g_hImgAssot, $ico1[1], 0)
  532.                         If @error Then
  533.                             _ArrayAdd2($g_aExtBlack, $sExt) ; Если ошибка, то добавляем расширение в чёрный список
  534.                             Return SetError(1, 0, -1)
  535.                         EndIf
  536.                     EndIf
  537.                 Case 3
  538.                     _GUIImageList_AddIcon($g_hImgAssot, $ico1[1], $ico1[2])
  539.                     If @error Then
  540.                         _ArrayAdd2($g_aExtBlack, $sExt) ; Если ошибка, то добавляем расширение в чёрный список
  541.                         Return SetError(1, 0, -1)
  542.                     EndIf
  543.             EndSwitch
  544.             _ArrayAdd2($g_aExtAssot, $sExt) ; Иначе добавляем расширение в белый список
  545.             Return SetError(0, 0, $g_aExtAssot[0])
  546.             ; MsgBox(4096, "Информация", "Количество изображений: " & _GUIImageList_GetImageCount($g_hImgAssot))
  547.             ; $sText = ''
  548.             ; For $i = 0 To $g_aExtAssot[0]
  549.             ; $sText &= $g_aExtAssot[$i] & @LF
  550.             ; Next
  551.             ; MsgBox(0, 'Сообщение', $sText)
  552.         EndIf
  553.     Else
  554.         Return SetError(0, 0, $ind)
  555.     EndIf
  556. EndFunc   ;==>_Get_Num_ICO
  557.  
  558. Func _ArrayAdd2(ByRef $Array, $ext)
  559.     $Array[0] += 1
  560.     ReDim $Array[$Array[0] + 1]
  561.     $Array[$Array[0]] = $ext
  562. EndFunc   ;==>_ArrayAdd2
  563.  
  564. Func _ArraySearch2(ByRef $Array, $ext)
  565.     For $i = 1 To $Array[0]
  566.         If $ext = $Array[$i] Then Return SetError(0, 0, $i)
  567.     Next
  568.     Return SetError(1, 0, -1)
  569. EndFunc   ;==>_ArraySearch2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement