monarch684

Checking a CheckBox

11 posts in this topic

#1 ·  Posted (edited)

What is the difference between this:

$pForm = _IEGetObjByID($oIE,"createKnownAccountNotifyForm")
_IEFormElementCheckBoxSelect($pForm,"print")

which is not working and this:

$pForm = _IEGetObjByID($oIE,"createKnownAccountNotifyForm")
$oPrint = _IEFormElementGetObjByName($pForm,"print")
_IEAction($oPrint,"click")

which does work.

Error:

--> IE.au3 T3.0-1 Warning from function _IEFormElementCheckBoxSelect, $_IESTATUS_NoMatch

The reason I am asking, the first example is what I really need.  The checkbox I am trying to check is done so multiple times for each time I need to print a form from a web portal.  I noticed that when I have to click multiple times that the checkbox sometimes stays checked, so when the second example runs it unchecks the checkbox.  I need for the checkbox to be verified first before check or just default to the checked status.

Edited by monarch684
Added error message

Share this post


Link to post
Share on other sites



Can you show the HTML code for this "checkbox".

Share this post


Link to post
Share on other sites

maybe here:

??


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Yea, that was my original post about another issue.  This is a similar but separate issue.

Share this post


Link to post
Share on other sites

Snippet of the code

<form class="validateable" notify-form="true" id="createKnownAccountNotifyForm">
    <input data-mini="true" type="checkbox"  value="true" name="print" class="custom" id="createKnownAccountNotifyFormPrint"/>
    <label for="createKnownAccountNotifyFormPrint">Print</label>
    <input data-mini="true" type="checkbox" name="email" class="custom" value="true"  id="createKnownAccountNotifyFormEmail"/>
    <label for="createKnownAccountNotifyFormEmail">Email</label>

    <blockquote> 
    
        <input data-mini="true" type="checkbox" name="copyMe" class="custom" value="true"  id="createKnownAccountNotifyFormCopyMe" checkbox-dependant="createKnownAccountNotifyFormEmail" disabled/>
        <label for="createKnownAccountNotifyFormCopyMe">Copy me</label>
        </blockquote>
</form>

The code in it's entirety is attached.

portal.html

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

So I made this test script:

#include <ie.au3>

_Example()
Func _Example()
    Local $oIE = _IECreate()
    ; REMARK:
    ; Copy to Clipboard HTML Snippet before run this example
    ; as this following line use it
    _IEDocWriteHTML($oIE, ClipGet())
    Local $pForm = _IEGetObjById($oIE, "createKnownAccountNotifyForm")
    _IEFormElementCheckBoxSelect($pForm, 1, "", 1, "byIndex")
EndFunc   ;==>_Example

 

this is ok, working well.

REMARK: you must copy to clipboard your HTML snippet from Post #6

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Yes this does work when I copy the snippet, but when I run it inline with the current script does not work.

Share this post


Link to post
Share on other sites

Bumping this topic as I really need to figure this out before next Monday.  This script is ran once a week and when it errors my guys have no clue how to click a button even though they have been instructed.

I have a thought on how to possibly approach this differently.  Throwing in a If Else statement.  I am at a lose on how to properly write the syntax.  Here is what I have:

Local $pForm = _IEGetObjById($oIE, "createKnownAccountNotifyForm")
   if StringInStr('<label class="ui-focus ui-checkbox-off ui-btn ui-btn-corner-all ui-mini ui-btn-icon-left ui-btn-up-a" for="createKnownAccountNotifyFormPrint" data-theme="a" data-mini="true" data-icon="checkbox-off" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperEls="span"><span class="ui-btn-inner"><span class="ui-btn-text">Print</span><span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">&nbsp;</span></span></label>','ui-checkbox-off') Then
      $oPrint = _IEFormElementGetObjByName($pForm,"print")
      _IEAction($oPrint,"click")
   Endif

This always returns true, so my script still unchecks the box.

Share this post


Link to post
Share on other sites

Here is what I came up with.

if IsDeclared("sRan") Then
      if $sRan = 0 Then
         Local $pForm = _IEGetObjById($oIE, "createKnownAccountNotifyForm")
         $oPrint = _IEFormElementGetObjByName($pForm,"print")
         _IEAction($oPrint,"click")
         Global $sRan = 1
      EndIf

    Else
      Local $pForm = _IEGetObjById($oIE, "createKnownAccountNotifyForm")
      $oPrint = _IEFormElementGetObjByName($pForm,"print")
      _IEAction($oPrint,"click")
      Global $sRan = 1
   EndIf

 

Share this post


Link to post
Share on other sites

Is this works for you now ?


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

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