Что нового

Запуск нескольких копий скрипта

Gorenich

ГорыНыЧ
Сообщения
38
Репутация
0
Всем привет!
Помогите запустить скрипт несколько раз,а то одна копия запускается и не дает запустить еще одну копию.
Код:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <File.au3>

Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 1)

Global $sTitle = 'Vservices', $aLogin, $iNumberStart, $oIE

If WinExists($sTitle & '{[/@$@\]}') Then Exit
AutoItWinSetTitle($sTitle & '{[/@$@\]}')

_Get_Array_Login($aLogin)
If @error Then
    MsgBox(16, 'Error', '_Get_Array_Login')
    Exit
EndIf

_InputBox($aLogin[0][0], $iNumberStart)

For $i = $iNumberStart To $aLogin[0][0]
    _Del_Cookie()
    _Login_Vservices($aLogin, $i, $oIE)
    If @error Then ContinueLoop
    For $j = 1 To 100
        _IENavigate($oIE, 'http://acesse.com/index.php?page=search/noresults&search=gorenich' & $j & '&type=web')
        If @error Then
            ConsoleWrite(@error & @LF)
        Else
            Local $oForm = _IEGetObjById($oIE, 'searchform')
            If Not @error Then
                Local $oSearch = _IEFormElementGetObjByName($oForm, 'search')
                If Not @error Then
                    Local $sSearch = _IEFormElementGetValue($oSearch)
                    If Not @error Then
                        ConsoleWrite($sSearch & @LF)
                    Else
                        ConsoleWrite(@error & @LF)
                    EndIf
                Else
                    ConsoleWrite(@error & @LF)
                EndIf
            Else
                ConsoleWrite(@error & @LF)
            EndIf
        EndIf
    Next
Next
If IsObj($oIE) Then _IEQuit($oIE)
_Del_Cookie()
MsgBox(64, 'Info', 'Все')

Func _Get_Array_Login(ByRef $a_Array)
    Local $s_FileIni = @ScriptDir & '\setting.ini', $a_SectionNames, $a_Section, $i_Count, $f_Yes

    If Not FileExists($s_FileIni) Then Return SetError(1)
    $a_SectionNames = IniReadSectionNames($s_FileIni)
    If @error Then Return SetError(1)
    If IsArray($a_Array) Then $a_Array = 0
    Dim $a_Array[$a_SectionNames[0] + 1][2]
    For $i = 1 To $a_SectionNames[0]
        $a_Section = IniReadSection($s_FileIni, $a_SectionNames[$i])
        If @error Then ContinueLoop
        If $a_Section[0][0] <> 2 Then ContinueLoop
        $f_Yes = True
        For $j = 1 To $a_Section[0][0]
            If Not $a_Section[$j][1] Then
                $f_Yes = False
                ExitLoop
            EndIf
        Next
        If $f_Yes Then
            $i_Count += 1
            For $j = 0 To 1
                $a_Array[$i_Count][$j] = $a_Section[$j + 1][1]
            Next
        EndIf
    Next
    If Not $i_Count Then Return SetError(1)
    ReDim $a_Array[$i_Count + 1][2]
    $a_Array[0][0] = $i_Count
EndFunc   ;==>_Get_Array_Login

Func _InputBox($i_Max, ByRef $i_Number)
    Local $h_Gui, $nInputBox, $nOk, $nCancel, $sInput
    $h_Gui = GUICreate($sTitle, 250, 120, -1, -1, $WS_OVERLAPPED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
    GUICtrlCreateLabel('Введите номер, с которого начнем (max = ' & $i_Max & '):', 5, 10, 230, 18, $ES_CENTER)
    $nInputBox = GUICtrlCreateInput('1', 100, 30, 50, 20, BitOR($ES_NUMBER, $ES_CENTER))
    $nOk = GUICtrlCreateButton('OK', 40, 60, 65, 25)
    GUICtrlSetTip(-1, 'Выбрать введенный номер')
    GUICtrlSetCursor(-1, 0)
    $nCancel = GUICtrlCreateButton('Выход', 145, 60, 65, 25)
    GUICtrlSetTip(-1, 'Выход из программы')
    GUICtrlSetCursor(-1, 0)
    GUISetState()

    While 1
        $sInput = GUICtrlRead($nInputBox)
        If Number($sInput) > $i_Max Then
            GUICtrlSetData($nInputBox, $i_Max)
        EndIf
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $nCancel
                If MsgBox(36, $sTitle, 'Вы уверены, что хотите выйти из программы?', 0, $h_Gui) = 6 Then Exit
            Case $nOk
                $sInput = GUICtrlRead($nInputBox)
                If Number($sInput) Then
                    $i_Number = $sInput
                    GUIDelete($h_Gui)
                    Return
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>_InputBox

Func _Login_Vservices($a_Array, $i_Index, ByRef $o_Obj)
    Local $s_Url_Avtor = 'http://vservices.acesse.com/memberLogin.php?service=12', $o_Form, _
            $o_Inputs, $s_Url_After, $i_Error = 1

    If IsObj($o_Obj) Then
        _IEQuit($o_Obj)
        If @error Then Return SetError(1)
    EndIf
    $o_Obj = _IECreate()
    If @error Then Return SetError(1)
    For $i = 1 To 1
        _IENavigate($o_Obj, $s_Url_Avtor)
        If @error Then ExitLoop
        $o_Form = _IEFormGetCollection($o_Obj, 0)
        If @error Then ExitLoop
        $o_Inputs = _IETagNameGetCollection($o_Form, 'input')
        If @error Then ExitLoop
        For $o_Input In $o_Inputs
            If $o_Input.type == 'text' Then
                _IEFormElementSetValue($o_Input, $a_Array[$i_Index][0])
                If @error Then ExitLoop 2
            EndIf
            If $o_Input.type == 'password' Then
                _IEFormElementSetValue($o_Input, $a_Array[$i_Index][1])
                If @error Then ExitLoop 2
            EndIf
        Next
        _IEFormSubmit($o_Form, 0)
        If @error Then ExitLoop
        _IELoadWait($o_Obj)
        $s_Url_After = _IEPropertyGet($o_Obj, 'locationurl')
        If @error Then ExitLoop
        If $s_Url_After == $s_Url_Avtor Then ExitLoop
        $i_Error = 0
    Next
    Return SetError($i_Error)
EndFunc   ;==>_Login_Vservices

Func _Del_Cookie()
    Local $a_Files_Cookie, $s_Path = @UserProfileDir & '\Cookies'

    $a_Files_Cookie = _FileListToArray($s_Path, '*.txt', 1)
    If @error Then Return
    For $i = 1 To $a_Files_Cookie[0]
        If Not FileDelete($s_Path & '\' & $a_Files_Cookie[$i]) Then
            FileSetAttrib($s_Path & '\' & $a_Files_Cookie[$i], '-RS')
            FileDelete($s_Path & '\' & $a_Files_Cookie[$i])
        EndIf
    Next
EndFunc   ;==>_Del_Cookie
Заранее большое спасибо!
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Gorenich,
Уберите эти строки:
Код:
If WinExists($sTitle & '{[/@$@\]}') Then Exit
AutoItWinSetTitle($sTitle & '{[/@$@\]}')
 
Верх