Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для proxy

Старожил


Сообщения: 460
Благодарности: 152

Профиль | Отправить PM | Цитировать


Код: Выделить весь код
#region: - Include
    #include <GUIConstantsEx.au3>
    #Include <Misc.au3>
    #include <WindowsConstants.au3>
#endregion

#region: - Option
    Opt('GUIOnEventMode',       1)
    Opt('MustDeclareVars',      1)
    Opt('TrayIconDebug',        1)
    Opt('TrayIconHide',         0)
#endregion

#region: - Global: Название и версия программы, ProID
    Global  $sProName, $sProVer, $sProNameVer
            $sProName     = 'TotalCmd Helper'
            $sProVer      = 'v1.0'
#endregion

#region: - Одна копия программы
    If _Singleton($sProNameVer & ' [ID] ' & $sProNameVer, 1) == 0 Then
        WinActivate('[CLASS:AutoIt v3 GUI; TITLE:' & $sProName & ']')
    Exit
EndIf
#endregion

#region: - Global
    Global  $hWinMain
    Global  $sFilePath, $hFilePath
            $sFilePath = 'c:\default.bar'
    Global  $hCountLineInFile, $hNowLineInFile
    Global  $sFileResult
#endregion

#region: GUI
    $hWinMain = GUICreate($sProName, 380, 135, -1, -1)
        GUISetOnEvent($GUI_EVENT_CLOSE,     '_Pro_Exit')

    GUICtrlCreateLabel('Пусть к файлу "default.bar":', 15, 10, 170, 25)
    $hFilePath = GUICtrlCreateInput($sFilePath, 15, 25, 250, 20)
    GUICtrlCreateButton('Выбрать файл', 15+250+2, 25-1, 100, 22)
        GUICtrlSetOnEvent(-1, '_Select_File')

    $hCountLineInFile = GUICtrlCreateLabel('Всего строк в файле:', 15, 50, 165, 18)
    GUICtrlCreateLabel('Сейчас обрабатывается строка:', 15, 50+20, 165, 18)
    $hNowLineInFile = GUICtrlCreateLabel('-', 15+165+5, 50+20, 380-30, 18)

    GUICtrlCreateButton('Проверить файл', 15, 50+20+21, 150, 25)
        GUICtrlSetOnEvent(-1, '_Check_File')
    GUICtrlCreateButton('Закрыть ALT+ESC', 15+150+2, 50+20+21, 150, 25)
        GUICtrlSetOnEvent(-1, '_Pro_Exit')
#endregion

#region: - После создания всех GUI
    HotKeySet('!{ESC}', '_Pro_Exit')
    GUISetState(@SW_SHOW, $hWinMain)
#endregion

#region: - Sleep, Exit
While 1
    Sleep(10)
WEnd

Func _Pro_Exit()
    HotKeySet('!{ESC}')
    Exit
EndFunc
#endregion

Func _Check_File()
    Local   $hFile, $iCountLineInFile, $i, $iLastNomber
    Local   $sButton, $sCmd, $sPath, $sMenu
    $iLastNomber = 0

    $sFilePath = GUICtrlRead($hFilePath)
    If NOT FileExists($sFilePath) Then
        MsgBox(64, 'Ошибка', 'Файл обработки отсутсвует:' & @CRLF & $sFilePath)
        Return
    EndIf

    $iCountLineInFile = IniRead($sFilePath, 'Buttonbar', 'Buttoncount', '<error>')
    If $iCountLineInFile <> '<error>' Then
        GUICtrlSetData($hCountLineInFile, 'Всего строк в файле:  ' & $iCountLineInFile*4+2)
        FileDelete($sFilePath & '.BAK')
    Else
        GUICtrlSetData($hCountLineInFile, 'Всего строк в файле:  Ошибка')
        Return
    EndIf

    For $i=1 To $iCountLineInFile
        $sButton = IniRead($sFilePath, 'Buttonbar', 'button' & $i, '<error>')
        $sCmd = StringStripWS(StringReplace(IniRead($sFilePath, 'Buttonbar', 'cmd' & $i, '<error>'), '"', ''), 1+2)
        $sPath = IniRead($sFilePath, 'Buttonbar', 'path' & $i, '<error>')
        $sMenu = IniRead($sFilePath, 'Buttonbar', 'menu' & $i, '<error>')

        GUICtrlSetData($hNowLineInFile, $i)

        If $sCmd <> '<error>' Then
            If NOT FileExists($sFilePath & '.BAK') Then _
                IniWrite($sFilePath & '.BAK', 'Buttonbar', 'Buttoncount', 0)

;~          MsgBox(0, $i, $sCmd)

            If FileExists($sCmd) Then
                $iLastNomber += 1
                IniWrite($sFilePath & '.BAK', 'Buttonbar', 'button' & $iLastNomber, $sButton)
                IniWrite($sFilePath & '.BAK', 'Buttonbar', 'cmd'    & $iLastNomber, $sButton)
                IniWrite($sFilePath & '.BAK', 'Buttonbar', 'path'   & $iLastNomber, $sButton)
                IniWrite($sFilePath & '.BAK', 'Buttonbar', 'menu'   & $iLastNomber, $sButton)
            EndIf
        EndIf
    Next

    IniWrite($sFilePath & '.BAK', 'Buttonbar', 'Buttoncount', $iLastNomber)
    FileCopy ($sFilePath & '.BAK', $sFilePath, 1)
    FileDelete($sFilePath & '.BAK')
    GUICtrlSetData($hNowLineInFile, 'Готово')
EndFunc

Func _Select_File()
    Local   $sSelectFile
    $sSelectFile = FileOpenDialog('Выбирите файл "default.bar"', @ProgramFilesDir, '(default.bar)', 1+2, 'default.bar', $hWinMain)
    If $sSelectFile == '' Then Return
    $sFilePath = $sSelectFile
    GUICtrlSetData($hFilePath, $sFilePath)
EndFunc
осталось только доделать обработку на проверку отнасительных путей и спец. комманд тотола

-------
Мысли-читатель сломался, может подробней расскажите?
А где исходный код? Или мы стихи обсуждаем?! )) Настройки темы > Решено ?

Это сообщение посчитали полезным следующие участники:

Отправлено: 05:05, 14-03-2009 | #2