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

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

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

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

   

sproxy



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


Код:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=C:\Put to FTP GUI.exe
#AutoIt3Wrapper_Compression=4
#EndRegion
;**** Directives created by AutoIt3Wrapper_GUI ****
 
#region: - Option
    AutoItSetOption ('GUIOnEventMode',      1)
    AutoItSetOption ('MustDeclareVars',     1)
    AutoItSetOption ('TrayIconDebug',       1)
    AutoItSetOption ('TrayIconHide',        1)
    AutoItSetOption ('WinDetectHiddenText', 1)
#endregion
 
#region: - Include

;~  #include <ButtonConstants.au3>
;~  #include <ComboConstants.au3>
;~  #include <Constants.au3>
;~  #Include <Date.au3>

    #include <EditConstants.au3>
    #include <.FTP.au3>
    #include <GuiConstantsEx.au3>
;~  #include <GUICtrlSetOnHover_UDF.au3>
;~  #include <GuiIPAddress.au3>
;~  #include <GuiListBox.au3>
;~  #include <GuiListView.au3>
;~  #include <GuiSlider.au3>
;~  #include <GuiStatusBar.au3>
;~  #Include <GuiTab.au3>
;~  #include <GuiToolbar.au3>
;~  #include <inet.au3>
;~  #include <ListBoxConstants.au3>
;~  #include <ListViewConstants.au3>
;~  #include <Registry_UDFs.au3>
;~  #include <_SMTP_Mail.au3>
;~  #Include <StaticConstants.au3>
;~  #Include <TabConstants.au3>

    #include <WindowsConstants.au3>
#endregion
 
Global  $win_main, $win_main_title, $win_main_title_Module, $name_module_file, $read_log, $process, $result, $process_old, $result_old
        $win_main_title
= 'Put to FTP GUI'
        $win_main_title_Module = 'Put to FTP Module'
        $name_module_file = 'Put to FTP Module.exe'
        $read_log = 0
        $process_old = '34567890serdrftgyhuji%$^&*SERSERSERH%&WCEC&T&B*OB*OB*O'
        $result_old = 0
Global  $oCOM_Error, $oRichText, $GUIActiveX, $hRichEdit, $color_time
        $color_time
= 0x5b5b5b
Global  $ftp_server, $ftp_login, $ftp_pass, $up_ftp, $tooltip_ftp, $ftp_file_local, $ftp_folder, $ftp_file_ftp
        $ftp_server
= 'ftp.narod.ru'
        $ftp_login = 'pro-ip-test'
        $ftp_pass = 'pro-ip-test147258369'
 
        $ftp_file_local = 'c:\boot.ini'
        $ftp_folder = '/'
        $ftp_file_ftp = 'booot'
 
;~ Главное окно
$win_main   =   GUICreate($win_main_title, 400, 400, -1, -1)
                    GUISetOnEvent($GUI_EVENT_CLOSE,     '_Exit_pro')
;~                  WinSetOnTop($win_main_title, '', 1)
 
;~ Лог
                GUICtrlCreateLabel('Ход выполнения операции:', 10, 10, 350, 20)
$oCOM_Error =   ObjEvent('AutoIt.Error', 'MyErrFunc')
$oRichText  =   ObjCreate('RICHTEXT.RichtextCtrl.1')
$GUIActiveX =   GUICtrlCreateObj($oRichText, 10, 10, 400, 260)
                    GUICtrlSetPos(-1, 10, 30, 380, 100)
$hRichEdit  =   ControlGetHandle($win_main, '', 'RichTextWndClass1')
                    DllCall('user32.dll', 'long', 'SendMessage', 'hwnd', $hRichEdit, 'int', $EM_SETREADONLY, 'int', True, 'int', 0)
 
;~ Поля
                    GUICtrlCreateLabel('FTP сервер:', 10, 145, 200, 20)
$ftp_server     =   GUICtrlCreateInput('ftp.narod.ru', 10, 160, 380, 20)
 
                    GUICtrlCreateLabel('FTP логин:', 10, 145+40, 70, 20)
$ftp_login      =   GUICtrlCreateInput('pro-ip-test', 10, 160+40, 185, 20)
 
                    GUICtrlCreateLabel('FTP пароль:', 10+185+10, 145+40, 70, 20)
$ftp_pass       =   GUICtrlCreateInput('pro-ip-test147258369', 10+185+10, 160+40, 185, 20)
 
                    GUICtrlCreateLabel('Локальный файл:', 10, 145+80, 200, 20)
$ftp_file_local =   GUICtrlCreateInput('c:\boot.ini', 10, 160+80, 380, 20)
 
                    GUICtrlCreateLabel('Название файл на FTP:', 10, 145+120, 200, 20)
$ftp_file_ftp   =   GUICtrlCreateInput('new_file_2', 10, 160+120, 380, 20)
 
;~ Кнопки
Global  $btshow_hide_mosule
 
GUICtrlCreateButton('Отправить файл на FTP', 10, 310, 150, 25)
    GUICtrlSetOnEvent(-1, '_Start_put_to_FTP')
GUICtrlCreateButton('Отменить отправку', 10+150+10, 310, 150, 25)
    GUICtrlSetOnEvent(-1, '_Cancel_put_to_FTP')
$btshow_hide_mosule = GUICtrlCreateButton('Показать окно Модуля FTP', 10, 340, 150, 25)
    GUICtrlSetOnEvent(-1, '_Show_hide_win_Module')
GUICtrlCreateButton('Закрыть Модуль FTP', 10+150+10, 340, 150, 25)
    GUICtrlSetOnEvent(-1, '_Close_Module')
GUICtrlCreateButton('Закрыть программу (все)', 10+150+10, 370, 150, 25)
    GUICtrlSetOnEvent(-1, '_Exit_pro')
 
#region: - После создания GUI
    GUISetState(@SW_SHOW, $win_main)
;~  GUISetState(@SW_HIDE, $win_main)
#endregion
 
While 1
    Sleep(10)
    ToolTip('WinGetState окна Put to FTP Module:' & @TAB & WinGetState($win_main_title_Module), 10, 70)
    If $read_log = 1 Then _Read_log()
WEnd
 
Func _Exit_pro()
    _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
    _Write_GUI_Log('Выход из программы', 1, 0x000000)
    _Write_GUI_Log(@CRLF)
 
    If ProcessExists($name_module_file) Then
        If MsgBox(1, $win_main_title & ': выход', 'Модуль отправка файла на FTP еще работает.' & @CRLF & 'Закрыть его принудительно?') == 1 Then
            $read_log = 0
            ProcessClose($name_module_file)
 
            _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
            _Write_GUI_Log('Модуль отправки на FTP закрыт', 1, 0x000000)
            _Write_GUI_Log(@CRLF)
 
        Else
            _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
            _Write_GUI_Log('Отмена выхода из программы', 1, 0x000000)
            _Write_GUI_Log(@CRLF)
 
            Return
        EndIf
    EndIf
    Exit
EndFunc
 
Func _Show_hide_win_Module()
    Local $state
    If ProcessExists($name_module_file) <> 0 Then
        $state = WinGetState($win_main_title_Module)
        If $state <> 0 AND $state == 5 Then
            WinSetState($win_main_title_Module, '', @SW_SHOW)
            GUICtrlSetData($btshow_hide_mosule, 'Скрыть окно Модуля FTP')
 
            _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
            _Write_GUI_Log('Окно модуля FTP показанно', 1, 0x000000)
            _Write_GUI_Log(@CRLF)
 
        ElseIf $state <> 0 AND $state <> 5 Then
            WinSetState($win_main_title_Module, '', @SW_HIDE)
            GUICtrlSetData($btshow_hide_mosule, 'Показать окно Модуля FTP')
 
            _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
            _Write_GUI_Log('Окно модуля FTP скрыто', 1, 0x000000)
            _Write_GUI_Log(@CRLF)
 
        EndIf
    EndIf
EndFunc
 
Func _Close_Module()
    If ProcessExists($name_module_file) <> 0 Then
        $read_log = 0
        ProcessClose($name_module_file)
 
        _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
        _Write_GUI_Log('Модуль отправки на FTP закрыт', 1, 0x000000)
        _Write_GUI_Log(@CRLF)
 
    EndIf
EndFunc
 
Func _Cancel_put_to_FTP()
    If ProcessExists($name_module_file) <> 0 Then
        $read_log = 0
        ProcessClose($name_module_file)
 
        _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
        _Write_GUI_Log('Отправка на FTP завершена', 1, 0x000000)
        _Write_GUI_Log(@CRLF)
 
    EndIf
EndFunc
 
Func _Start_put_to_FTP()
    If ProcessExists($name_module_file) == 0 Then
;~      Проверку надо сделать посерьезней...
        If GUICtrlRead($ftp_server) == '' OR GUICtrlRead($ftp_login) == '' OR GUICtrlRead($ftp_pass) == '' OR GUICtrlRead($ftp_file_local) = '' OR GUICtrlRead($ftp_file_ftp) == '' Then
            _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
            _Write_GUI_Log('Неверно заполненны дынне, исправте их и повторите попытку.', 1, 0x000000)
            _Write_GUI_Log(@CRLF)
 
            Return
        EndIf
 
        _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
        _Write_GUI_Log('Старт отправки данных на FTP', 1, 0x000000)
        _Write_GUI_Log(@CRLF)
 
        ShellExecute($name_module_file, '"' & GUICtrlRead($ftp_server) & '" "' & GUICtrlRead($ftp_login) & '" "' & GUICtrlRead($ftp_pass) & '" "' & GUICtrlRead($ftp_file_local) & '" "' & GUICtrlRead($ftp_file_ftp) & '"')
        $read_log = 1
    Else
        _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
        _Write_GUI_Log('Модуль отправка файла на FTP уже работает, закройте его и повторите попытку.', 1, 0x000000)
        _Write_GUI_Log(@CRLF)
    EndIf
EndFunc
 
Func _Read_log()
    $process = ''
    $result = ''
 
    $process = ControlGetText($win_main_title_Module, 'Последнее сообщение выполняемой операции:', 'Edit1')
    $result = ControlGetText($win_main_title_Module, 'Последнее сообщение выполняемой операции:', 'Edit2')
 
    If $process <> '' AND $process <> $process_old Then
        If $process == '<stop_read_log>' Then
            $read_log = 0
            $result_old = 0
            MsgBox(0, '', 'Stop read log')
 
            Return
        EndIf
 
        $process_old = $process
        $result_old = 1
 
        _Write_GUI_Log('[' & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC) & '] ', 1, $color_time)
        _Write_GUI_Log($process & ':  ', 1, 0x000000)
;~      _Write_GUI_Log(@CRLF)
    EndIf
 
    If $result <> '' AND $result_old == 1 Then
        $result_old = 0
 
        If $result == 'ОК' Then
            _Write_GUI_Log('OK', 1, 0x008000, 0)
            _Write_GUI_Log(@CRLF)
        Else
            _Write_GUI_Log($result, 1, 0x0000ff, 0)
            _Write_GUI_Log(@CRLF)
        EndIf
    EndIf
EndFunc
 
;~ Лог функции
Func _Write_GUI_Log($sData, $iAppend=True, $iColor=0, $iBold=False, $iItalic=False, $iUnderline=False, $iFontSize=8)
    Local $sCurrent_Data = $oRichText.Text
 
    Local $iSelStart = StringLen($sCurrent_Data)
    Local $iSelLength = StringLen($sData)
 
    With $oRichText
        .SelStart = $iSelStart
        .SelLength = 0
 
        If $iAppend Then
            .SelText = $sData
        Else
            .Text = $sData
        EndIf
 
        .SelStart = $iSelStart
        .SelLength = $iSelLength
 
        .SelFontSize = $iFontSize
        .SelColor = $iColor
        .SelBold = $iBold
        .SelItalic = $iItalic
        .SelUnderline = $iUnderline
 
        .SelStart = $iSelStart + $iSelLength
    EndWith
EndFunc
 
Func MyErrFunc()
    Msgbox(16, "AutoItCOM Error", _
        "We intercepted a COM Error !"      & @CRLF  & @CRLF & _
        "err.description is: "    & @TAB & $oCOM_Error.Description    & @CRLF & _
        "err.windescription:"     & @TAB & $oCOM_Error.WinDescription & @CRLF & _
        "err.number is: "         & @TAB & Hex($oCOM_Error.Number,8)  & @CRLF & _
        "err.lastdllerror is: "   & @TAB & $oCOM_Error.LastDllError   & @CRLF & _
        "err.scriptline is: "     & @TAB & $oCOM_Error.ScriptLine     & @CRLF & _
        "err.source is: "         & @TAB & $oCOM_Error.Source         & @CRLF & _
        "err.helpfile is: "       & @TAB & $oCOM_Error.HelpFile       & @CRLF & _
        "err.helpcontext is: "    & @TAB & $oCOM_Error.HelpContext, 5) ;Will automatically continue after 5 seconds
 
    Local $iErr = $oCOM_Error.Number
    If $iErr = 0 Then $iErr = -1
 
    SetError($iErr)  ; to check for after this function returns
Endfunc


Всего записей: 556 | Зарегистр. 21-11-2007 | Отправлено: 22:33 03-02-2009 | Исправлено: sproxy, 06:29 04-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