Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 2)

Модерирует : gyra, Maz

Widok (01-06-2010 13:08): Лимит страниц. Продолжаем здесь.  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

sproxy



Full Member
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору


Код:
#NoTrayIcon
HotKeySet('^x', '_Exit_pro_Ctrl_X')
 
#region: - Include
    #include <EditConstants.au3>
    #include <file.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
#endregion
 
#region: - Option

    AutoItSetOption ('GUIOnEventMode',      1)
    AutoItSetOption ('MustDeclareVars',     1)
    AutoItSetOption ('TrayIconDebug',       1)
    AutoItSetOption ('TrayIconHide',        1)
#endregion
 
Global  $cmd_line[7]
Global  $win_main, $win_main_title, $i, $what_search, $where_search, $where_to_move, $exceptions_input, $exceptions, $button_search, $result, $how_much_label, $how_much_result, $result_null
        $win_main_title
= 'Поиск файлов по маске и перемещение'
        $cmd_line[1] = 'show' ;~ show - копировать, hide - перемещать
        $cmd_line[2] = 'copy' ;~ copy - копировать, move - перемещать
        $cmd_line[3] = '*.doc'
        $cmd_line[4] = 'd:\'
        $cmd_line[5] = 'd:\backup\'
        $cmd_line[6] = 'RECYCLER,System Volume Information,WebServer,FTP,Софт'
        $result_null = 400
 
If $CmdLine[0] > 0 Then
    For
$i = 1 to $CmdLine[0]
        $cmd_line[$i] = $CmdLine[$i]
    Next
EndIf

 
$win_main = GUICreate($win_main_title, 400, 550, -1, -1, $WS_CAPTION+$WS_SYSMENU)
                GUISetIcon(@SystemDir & '\shell32.dll', 25)
                    GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit_pro')
 
GUICtrlCreateLabel('Что искать:', 10, 15, 85, 15)
$what_search = GUICtrlCreateInput($cmd_line[3], 10+85, 10, 295, 20)
 
GUICtrlCreateLabel('Где искать:', 10, 15+30, 85, 15)
$where_search = GUICtrlCreateInput($cmd_line[4], 10+85, 10+30, 295, 20)
 
GUICtrlCreateLabel('Переносить в:', 10, 15+30*2, 85, 15)
$where_to_move = GUICtrlCreateInput($cmd_line[5], 10+85, 10+30*2, 295, 20)
 
GUICtrlCreateLabel('Исключать:', 10, 15+30*3, 85, 15)
;~ указывать через запятую БЕЗ пробелов:
$exceptions_input = GUICtrlCreateInput($cmd_line[6], 10+85, 10+30*3, 295, 20)
 
$button_search = GUICtrlCreateButton('Поиск с перемещением', 10+84, 10+30*4, 150, 25)
    GUICtrlSetOnEvent(-1, '_Start_search')
 
$button_search = GUICtrlCreateButton('Поиск с копированием', 10+81+160, 10+30*4, 140, 25)
    GUICtrlSetOnEvent(-1, '_Start_search')
 
GUICtrlCreateButton('Закрыть Ctrl+X', 9+88+205, 10+37*4, 90, 25)
    GUICtrlSetOnEvent(-1, '_Exit_pro')
 
$how_much_label = GUICtrlCreateLabel('Результат поиска, всего найденно: -', 10, 10+32*5, 290, 15)
$result = GUICtrlCreateEdit('', 10, 10+30*6, 400-20, 345, $ES_READONLY+$ES_AUTOVSCROLL+$WS_VSCROLL+$WS_HSCROLL)
 
If $cmd_line[1] == 'show' Then
    GUISetState()
EndIf
 
While 1
    Sleep(100)
WEnd
 
Func _Exit_pro()
    HotKeySet('^x')
    Exit
EndFunc
 
Func _Exit_pro_Ctrl_X()
    _Exit_pro()
EndFunc
 
Func _Start_copy()
    $CmdLine[2] = 'copy'
    _Start_search()
EndFunc
 
Func _Start_move()
    $CmdLine[2] = 'move'
    _Start_search()
EndFunc
 
Func _Start_search()
    Local   $error_msg[2]
            $error_msg[0] = 'Укажите данные'
            $error_msg[1] = ''
 
    If GUICtrlRead($what_search) == '' Then
        $error_msg[0] &= @CRLF & @TAB & '- что искать'
        If $error_msg[1] == '' Then $error_msg[1] = $what_search
    EndIf
 
    If GUICtrlRead($where_search) == '' Then
        $error_msg[0] &= @CRLF & @TAB & '- где искать'
        If $error_msg[1] == '' Then $error_msg[1] = $where_search
    EndIf
 
    If GUICtrlRead($where_to_move) == '' Then
        $error_msg[0] &= @CRLF & @TAB & '- переносить в'
        If $error_msg[1] == '' Then $error_msg[1] = $where_to_move
    EndIf
 
    If $error_msg[1] <> '' Then
        GUICtrlSetData($result, @CRLF & '===================================================' & @CRLF, 1)
        GUICtrlSetData($result, '  ОШИБКА УСЛОВИЙ ПОИСКА:     ', 1)
        GUICtrlSetData($result, $error_msg[0], 1)
        GUICtrlSetData($result, @CRLF & '------------------------------------------------------------------------------------------------------' & @CRLF, 1)
        GUICtrlSetState($error_msg[1], $GUI_FOCUS)
        Return
    EndIf
 
    If StringRight(GUICtrlRead($where_search), 1) <> '\' Then GUICtrlSetData($where_search, GUICtrlRead($where_search) & '\')
    If StringRight(GUICtrlRead($where_to_move), 1) <> '\' Then GUICtrlSetData($where_to_move, GUICtrlRead($where_to_move) & '\')
 
    GUICtrlSetData($result, @CRLF & '===================================================' & @CRLF, 1)
    GUICtrlSetData($result, '  СТАРТ В:     ' & GUICtrlRead($where_search) & @CRLF, 1)
    GUICtrlSetData($result, '  ПОИСК:       ' & GUICtrlRead($what_search), 1)
    GUICtrlSetData($result, @CRLF & '------------------------------------------------------------------------------------------------------' & @CRLF, 1)
 
    $how_much_result = 0
    $exceptions = StringRegExpReplace(GUICtrlRead($exceptions_input), ',', '\\\\\|\\\\')
    $exceptions = '\\' & $exceptions & '\\'
;~  If FileExists(@ScriptDir & '\result_search.log') Then FileDelete(@ScriptDir & '\result_search.log')
    _Search(GUICtrlRead($where_search))
 
    GUICtrlSetData($result, '------------------------------------------------------------------------------------------------------' & @CRLF, 1)
    GUICtrlSetData($result, '  НАЙДЕННО РЕЗУЛЬТАТОВ:  ' & $how_much_result & @CRLF, 1)
EndFunc
 
Func _Search($folder_path)
    Local $first_search, $file_path, $file, $what_search_reg
    If StringRegExp($folder_path, $exceptions) Then Return
 
    $what_search_reg = StringRegExpReplace(GUICtrlRead($what_search), '\.+', '\\\.')
    $what_search_reg = StringRegExpReplace($what_search_reg, '\*+', '\.\*')
    $folder_path = StringRegExpReplace($folder_path, '\\+$', '')
    $first_search = FileFindFirstFile($folder_path & '\*')
    If $first_search == -1 Then
        Return
    EndIf
 
    While 1
        $file = FileFindNextFile($first_search)
        If @error = 1 Then ExitLoop
 
        $file_path = $folder_path & '\' & $file
        _Search($file_path)
 
        If NOT StringInStr(FileGetAttrib($file_path), 'D') AND StringRegExp($file, $what_search_reg) Then
            $how_much_result += 1
            If $how_much_result > $result_null Then
                $result_null *= 2
                GUICtrlSetData($result, '')
            EndIf
 
            If $cmd_line[2] == 'copy' Then
                FileCopy($file_path, StringReplace($file_path, GUICtrlRead($where_search), GUICtrlRead($where_to_move)), 9)
            ElseIf $cmd_line[2] == 'move' Then
                FileMove($file_path, StringReplace($file_path, GUICtrlRead($where_search), GUICtrlRead($where_to_move)), 9)
            EndIf
 
            GUICtrlSetData($how_much_label, 'Результат поиска, всего найденно: ' & $how_much_result)
            GUICtrlSetData($result, $file_path & @CRLF, 1)
;~          _FileWriteLog(@ScriptDir & '\result_search.log', $file_path)
        EndIf
    WEnd
 
    FileClose($first_search)
EndFunc


Всего записей: 556 | Зарегистр. 21-11-2007 | Отправлено: 19:15 13-02-2009 | Исправлено: sproxy, 19:22 13-02-2009
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 2)
Widok (01-06-2010 13:08): Лимит страниц. Продолжаем здесь.


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru