Sign in to follow this  
Followers 0
phew

checking checkbox on website

11 posts in this topic

heeloowww,

i'm trying to check the AGB checkbox on http://www.meta-sms.de/

honestly i didnt get this _IE...Obj.. functions really..

here is my code:

#include <IE.au3>

$url = "http://www.meta-sms.de/"
$oIE = _IECreate ($url, 1)

$checkbox = _IEFormGetObjByName ($oIE, "ID_CheckAGB")
$check = _IEFormElementCheckBoxSelect($checkbox, "ID_CheckAGB", "", 1, "byIndex", 0)
MsgBox(0, "", $check)

it always returns @error = 3 (($_IEStatus_InvalidDataType) = Invalid Data Type)

what am i doing wrong? someone can please give me a working example?

Share this post


Link to post
Share on other sites



You had it mostly correct. You might even be able to actually use _IEFormElementCheckBoxSelect, but in most cases a generic 'click' will do.

#include <IE.au3>

$url = "http://www.meta-sms.de/"
$oIE = _IECreate ($url, 1)

$checkbox = _IEGetObjByName ($oIE, "ID_CheckAGB")
$check=_IEAction($checkbox,"click")
MsgBox(0, "", $check)

Share this post


Link to post
Share on other sites

heeloowww,

i'm trying to check the AGB checkbox on http://www.meta-sms.de/

honestly i didnt get this _IE...Obj.. functions really..

here is my code:

#include <IE.au3>

$url = "http://www.meta-sms.de/"
$oIE = _IECreate ($url, 1)

$checkbox = _IEFormGetObjByName ($oIE, "ID_CheckAGB")
$check = _IEFormElementCheckBoxSelect($checkbox, "ID_CheckAGB", "", 1, "byIndex", 0)
MsgBox(0, "", $check)

it always returns @error = 3 (($_IEStatus_InvalidDataType) = Invalid Data Type)

what am i doing wrong? someone can please give me a working example?

_IEFormElementCheckBoxSelect needs you to pass a Form element to it - $checkbox is an <INPUT> form element.

#include <IE.au3>

$url = "http://www.meta-sms.de/"
$oIE = _IECreate ($url, 1)

$oForm = _IEFormGetCollection($oIE, 0)
$check = _IEFormElementCheckBoxSelect($oForm, 0, "ID_CheckAGB", 1, "byIndex", 0)
MsgBox(0, "", $check)

Also, when using byIndex, the second parameter is the checkbox index (0 in this case)

Dale

p.s. @eviltoaster's method works for this specific case, but you need to make changes if there is more than one checkbox and if you are not certain if it is check already there is additional code needed to see or you will uncheck it with that code...


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

it's still not working for me, msgbox shows up with "0" what means @error

SCITE Reply:
--> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch
--> IE.au3 Warning from function _IEFormElementCheckboxSelect, $_IEStatus_NoMatch

but thx for your reply

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Are you certain? The code I posted work fine for me over and over again.

Dale

p.s. the _IEAttach NoMatch is expected unless you already have the site up

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

when i execute this .au3 script as you have posted it the msgbox always shows "0"

Share this post


Link to post
Share on other sites

Mine works, shows a "1"

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

bah, i exactly use

#include <IE.au3>

$url = "http://www.meta-sms.de/"
$oIE = _IECreate ($url, 1)

$oForm = _IEFormGetCollection($oIE, 0)
$check = _IEFormElementCheckBoxSelect($oForm, 0, "ID_CheckAGB", 1, "byIndex", 0)
MsgBox(0, "", $check)

and my msgbox shows "0" <_<

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

haha that is so strange, now after pc reboot it works, also when i didn't change anything to the code o_O

thanks for your help guys

EDIT:

wtf, slowly i'm going crazy. now it worked for a few times and the msgbox showed me "1" and the box was checked, and without changing anything to the code it stopped working again - msgbox shows a 0. someone knows what i'm doing wrong?

Edited by phew

Share this post


Link to post
Share on other sites

Suggest you remove the try_attach from the _IECreate ( the 1 parameter). It is possible that after interacting with the page, the URL stays the same, but the elements on the page are changed with dynamic HTML that would cause trouble with the assumptions in the script. E.g. since the form has no name attribute you are grabbing it based on being the first form on the page, index 0 -- if a new form dynamically gets inserted at the top of the page, the form you want is no longer form 0.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

thanks for your help but that didn't work either - but doesn't matter, somehow it works when i compiled the *.au3, and i need it as *.exe anyways <_<

greetings,

phew

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0