Jump to content

Cant check checkbox!


Go to solution Solved by mLipok,

Recommended Posts

Posted (edited)

Hey, there is a checkbox on IE which I would like to manipulate.

The .HTML is as follows..

<td><input type="checkbox" value="557" name="stopCheck[]"></td>

I have tried this.. (using the IEFormElementCheckBoxSelect)

_IELoadWait($oIE)
Local $oForm = _IEFormGetCollection($oIE, 0)
_IEFormElementCheckBoxSelect($oForm, 0, "stopCheck[]", 1, "byIndex")

 

But it still will not check the box. I am either doing something wrong in $oForm with the IEFormGetCollection() or IEFormElementCheckBoxSelect() but can't figure out what >.> I followed the examples in the help files..

Any ideas? Thanks!

Edited by MirnesC2
Posted (edited)

are you sure  $oForm is an object ?

 

Look for ObjEvent in documentation

exacly for example with _ErrFunc($oError)

or just use

_IEErrorNotify ( True )

EDIT:

sorry better be this:

_IEErrorHandlerRegister()
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Welp so much for a simple script, running into problems around every corner it seems >.>

This is what I am looking to check off..

09RAlMU.png

  On 9/9/2013 at 7:15 PM, mlipok said:

 

are you sure  $oForm is an object ?

 

Look for ObjEvent in documentation

exacly for example with _ErrFunc($oError)

or just use

_IEErrorNotify ( True )

EDIT:

sorry better be this:

_IEErrorHandlerRegister()

That does sound like it could be the issue, it's most likely not hooked right to the box so it can't check it off.. which is what the error messages are saying I am assuming.

--> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch
--> IE.au3 V2.4-0 Error from function _IEFormElementGetCollection, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormElementGetCollection, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Warning from function _IEFormElementCheckboxSelect, $_IEStatus_NoMatch

 

How do I find the right object?

Posted

this is your problem:

  Quote

 

--> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

try to replace

_IELoadWait($oIE)
Local $oForm = _IEFormGetCollection($oIE, 0)
_IEFormElementCheckBoxSelect($oForm, 0, "stopCheck[]", 1, "byIndex")

with that:

_IELoadWait($oIE)
ConsoleWrite('IsObj($oIE) = ' & IsObj($oIE) & @CRLF)
$oForms = _IEFormGetCollection($oIE)
ConsoleWrite('IsObj($oForms) = ' & IsObj($oForms) & @CRLF)
For $oForm In $oForms
    ConsoleWrite('$oForm.name = ' & $oForm.name & @CRLF)
    ConsoleWrite('$oForm.id = ' & $oForm.id & @CRLF)
Next

Local $oForm = _IEFormGetCollection($oIE, 0)
_IEFormElementCheckBoxSelect($oForm, 0, "stopCheck[]", 1, "byIndex")

and show what you get in console

 

EDIT:

or just simply

add a new function:

Func _IE_test_FormCollection(ByRef $oIE)
    ConsoleWrite('! IsObj($oIE) = ' & IsObj($oIE) & @CRLF)
    $oForms = _IEFormGetCollection($oIE)
    ConsoleWrite('! IsObj($oForms) = ' & IsObj($oForms) & @CRLF)
    For $oForm In $oForms
        ConsoleWrite('! $oForm.name = ' & $oForm.name & @CRLF)
        ConsoleWrite('! $oForm.id = ' & $oForm.id & @CRLF)
    Next
EndFunc ;==>_IE_test_FormCollection

and change your script:

_IELoadWait($oIE)
_IE_test_FormCollection($oIE)
Local $oForm = _IEFormGetCollection($oIE, 0)
_IEFormElementCheckBoxSelect($oForm, 0, "stopCheck[]", 1, "byIndex")
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

take a look here:

'?do=embed' frameborder='0' data-embedContent>>

use this:

  1. _IE_test_FormElementCollection($oIE)
 
and give me the result of the function, which is visible in the console.
 
 
EDIT:
remeber to use AutoIt 3.3.9.20 BETA
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

  On 9/10/2013 at 4:34 AM, mlipok said:

 

take a look here:

'?do=embed' frameborder='0' data-embedContent>>

use this:

  1. _IE_test_FormElementCollection($oIE)
 
and give me the result of the function, which is visible in the console.
 
 
EDIT:

remeber to use AutoIt 3.3.9.20 BETA

 

Thats a useful .udf thanks for that!

 

output...

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\User\Desktop\ddd.au3"

--> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch

--> IE.au3 V2.4-0 Error from function _IEFormElementGetCollection, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementGetCollection, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType



! _IE_test_FormElementCollection:    IsObj($oIE) = 1

! _IE_test_FormElementCollection:    IsObj($oForms) = 1



! _IE_test_FormElementCollection:    $iForm_index = 0

! _IE_test_FormElementCollection:    $oForm "Type" = HTMLFormElement

! _IE_test_FormElementCollection:    $oForm.id = 0

! _IE_test_FormElementCollection:    $oForm.name = 0



!    _IE_test_FormElementCollection:    $iElement_index = 0

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="host" class="m-wrap small" type="text" placeholder="00000000">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = host



!    _IE_test_FormElementCollection:    $iElement_index = 1

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="port" class="m-wrap small" type="text" placeholder="80">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = port



!    _IE_test_FormElementCollection:    $iElement_index = 2

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="time" class="m-wrap small" type="text" placeholder="60">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = time



!    _IE_test_FormElementCollection:    $iElement_index = 3

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" checked="" value="Method Type">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 4

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="charge">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 5

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="css">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 6

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="syn">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 7

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="Hide" type="checkbox" value="yes">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = Hide



!    _IE_test_FormElementCollection:    $iElement_index = 8

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="goBtn" class="btn blue" type="submit" value="Go!">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = goBtn



! _IE_test_FormElementCollection:    $iForm_index = 1

! _IE_test_FormElementCollection:    $oForm "Type" = HTMLFormElement

! _IE_test_FormElementCollection:    $oForm.id = 0

! _IE_test_FormElementCollection:    $oForm.name = 0



!    _IE_test_FormElementCollection:    $iElement_index = 0

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="host" class="m-wrap medium" type="text" placeholder="web address">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = host



!    _IE_test_FormElementCollection:    $iElement_index = 1

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="port" type="hidden" value="80">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = port



!    _IE_test_FormElementCollection:    $iElement_index = 2

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="time" class="m-wrap small" type="text" placeholder="60">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = time



!    _IE_test_FormElementCollection:    $iElement_index = 3

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" checked="" value="xml">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 4

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="rude">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 5

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="mear">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 6

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="slow">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 7

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="get">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 8

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="post">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 9

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="method" type="radio" value="head">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = method



!    _IE_test_FormElementCollection:    $iElement_index = 10

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="goBtn" class="btn blue" type="submit" value="Go!">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = goBtn



! _IE_test_FormElementCollection:    $iForm_index = 2

! _IE_test_FormElementCollection:    $oForm "Type" = HTMLFormElement

! _IE_test_FormElementCollection:    $oForm.id = 0

! _IE_test_FormElementCollection:    $oForm.name = 0



!    _IE_test_FormElementCollection:    $iElement_index = 0

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="stopCheck[]" type="checkbox" value="2241">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = stopCheck[]



!    _IE_test_FormElementCollection:    $iElement_index = 1

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="stopbtn" class="btn red" type="submit" value="Stop!">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = stopbtn



! _IE_test_FormElementCollection:    $iForm_index = 3

! _IE_test_FormElementCollection:    $oForm "Type" = HTMLFormElement

! _IE_test_FormElementCollection:    $oForm.id = 0

! _IE_test_FormElementCollection:    $oForm.name = 0



!    _IE_test_FormElementCollection:    $iElement_index = 0

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="host2" class="m-wrap small" type="text" placeholder="000000">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = host2



!    _IE_test_FormElementCollection:    $iElement_index = 1

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="port2" class="m-wrap small" type="text" placeholder="80">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = port2



!    _IE_test_FormElementCollection:    $iElement_index = 2

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="times" class="m-wrap small" type="text" placeholder="15">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = times



!    _IE_test_FormElementCollection:    $iElement_index = 3

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="redirect" class="btn light-blue" type="submit" value="Redirect" !">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = redirect

--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementCheckboxSelect, $_IEStatus_InvalidDataType

>Exit code: 0    Time: 2.416

I think this the bit we are looking for is this..

! _IE_test_FormElementCollection:    $iForm_index = 2

! _IE_test_FormElementCollection:    $oForm "Type" = HTMLFormElement

! _IE_test_FormElementCollection:    $oForm.id = 0

! _IE_test_FormElementCollection:    $oForm.name = 0



!    _IE_test_FormElementCollection:    $iElement_index = 0

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="stopCheck[]" type="checkbox" value="2241">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = stopCheck[]



!    _IE_test_FormElementCollection:    $iElement_index = 1

!    _IE_test_FormElementCollection:    $oElement "Type" = HTMLInputElement

!    _IE_test_FormElementCollection:    $oElement "OuterHtml" = <input name="stopbtn" class="btn red" type="submit" value="Stop!">

!    _IE_test_FormElementCollection:    $oElement.id = 0

!    _IE_test_FormElementCollection:    $oElement.name = stopbtn

So how do we set it up to find the form/object now?

Posted

now tell me

With the new knowlege,

How you want to use the standard _IE function ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Solution
Posted

try this:

$oForm2 = _IEFormGetCollection ( $oIE , 2)
$oForm2_elCheck = _IEFormElementGetObjByName($oForm2,"stopCheck[]")
$oForm2_elCheck.checked = true

or this:

$oForm2 = _IEFormGetCollection ( $oIE , 2)
_IEFormElementCheckBoxSelect($oForm2, 0, "", 1, "byIndex")

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/11/2013 at 7:41 AM, mlipok said:

 

try this:

$oForm2 = _IEFormGetCollection ( $oIE , 2)
$oForm2_elCheck = _IEFormElementGetObjByName($oForm2,"stopCheck[]")
$oForm2_elCheck.checked = true

or this:

$oForm2 = _IEFormGetCollection ( $oIE , 2)
_IEFormElementCheckBoxSelect($oForm2, 0, "", 1, "byIndex")

Got it! Thanks for that and the udf

Posted

Tell me: Which one works ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...