Что нового

Как сделать грамотный обработчик ошибки в IE

Geerapd

Новичок
Сообщения
3
Репутация
0
Есть скрипт, который в IE находит форму и устанавливает флаг. Как правильно сделать , чтобы если форма была не найдена- скрипт выдал ошибку и приостановил работу?

Кусок скрипта:
Код:
$oInputSerch = _IEGetObjById($oIE, 'DEC')
_IEDocInsertText($oInputSerch, 'AutoIt')

$oInputs = _IETagNameGetCollection ($oIE, 'input')
For $oInput In $oInputs
    If $oInput.type == 'run' AND $oInput.value == 'on' Then
        _IEAction($oInput, "focus")
_IEAction($oInput, "selectall")
    _IEAction($oInput, "click")
    EndIf
Next



Я пытался сделать так, но скрипт - даже если нужная форма на сайте не появляется продолжает работать дальше , как будто успешно установил флаг :

Код:
$oInputSerch = _IEGetObjById($oIE, 'DEC')
_IEDocInsertText($oInputSerch, 'AutoIt')

$oInputs = _IETagNameGetCollection ($oIE, 'input')
For $oInput In $oInputs
    If $oInput.type == 'run' AND $oInput.value == 'on' Then
        _IEAction($oInput, "focus")
If @error = 3 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
If @error = 4 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
If @error = 5 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
_IEAction($oInput, "selectall")
If @error = 3 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
If @error = 4 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
If @error = 5 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
    _IEAction($oInput, "click")
   If @error = 3 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
If @error = 4 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
If @error = 5 Then
    MsgBox(16, "", "Не смогли включить")
EndIf
    EndIf
Next



Как сделать правильно?
 

InnI

AutoIT Гуру
Сообщения
4,912
Репутация
1,429
Код:
$oInputSerch = _IEGetObjById($oIE, 'DEC')
_IEDocInsertText($oInputSerch, 'AutoIt')

$oInputs = _IETagNameGetCollection ($oIE, 'input')
$Checked = False
For $oInput In $oInputs
    If $oInput.type == 'run' AND $oInput.value == 'on' Then
        _IEAction($oInput, "focus")
        _IEAction($oInput, "selectall")
        _IEAction($oInput, "click")
        $Checked = True
        ExitLoop
    EndIf
Next
If Not $Checked Then
    MsgBox(16, "", "Не смогли включить")
    Exit
EndIf
 
Автор
G

Geerapd

Новичок
Сообщения
3
Репутация
0
Код:
$oInputSerch = _IEGetObjById($oIE, 'DEC')
_IEDocInsertText($oInputSerch, 'AutoIt')

$oInputs = _IETagNameGetCollection ($oIE, 'input')
$Checked = False
For $oInput In $oInputs
    If $oInput.type == 'run' AND $oInput.value == 'on' Then
        _IEAction($oInput, "focus")
        _IEAction($oInput, "selectall")
        _IEAction($oInput, "click")
        $Checked = True
        ExitLoop
    EndIf
Next
If Not $Checked Then
    MsgBox(16, "", "Не смогли включить")
    Exit
EndIf
Код:
$oInputSerch = _IEGetObjById($oIE, 'DEC')
_IEDocInsertText($oInputSerch, 'AutoIt')

$oInputs = _IETagNameGetCollection ($oIE, 'input')
$Checked = False
For $oInput In $oInputs
    If $oInput.type == 'run' AND $oInput.value == 'on' Then
        _IEAction($oInput, "focus")
        _IEAction($oInput, "selectall")
        _IEAction($oInput, "click")
        $Checked = True
        ExitLoop
    EndIf
Next
If Not $Checked Then
    MsgBox(16, "", "Не смогли включить")
    Exit
EndIf
Работает!!)) Спасибо
 
Верх