Jump to content
Sign in to follow this  
naru

How to skip to fill IE textbox if amount is already exists

Recommended Posts

i am using this code for filling text box of IE : 

#include <IE.au3>

Func Quit()
    Exit
 EndFunc
$oIE = _IEAttach ("Home")
_IELoadWait($oIE)

Local $oStockKg = _IEGetObjById($oIE, "txtbuyingstockinkg0")
If IsObj($oStockKg) And StringStripWS($oStockKg.Value, 8) = "" Then
Local $iOutStanding, $iKg, $iGram, $oStockKg, $oStockGram, $sStockKg, $sStockGram
Local $oTds, $oTrs = _IETagNameGetCollection($oIE, "tr")
If IsObj($oTrs) Then
    For $i = 1 To $oTrs.Length
        $oTr = $oTrs($i)
        $oTds = _IETagNameGetCollection($oTr, "td")
        If IsObj($oTds) And $oTds.Length = 5 Then
            $iOutStanding = $oTds(1).InnerText
            $iKg = StringLeft($iOutStanding, StringInStr($iOutStanding, ".")-1)
            $iGram = StringTrimLeft($iOutStanding, StringInStr($iOutStanding, "."))
            $sStockKg = $oTds(3).FirstElementChild.getAttribute("id", 2)
            $oStockKg = _IEGetObjById($oIE, $sStockKg)
            If IsObj($oStockKg) Then
            $oStockKg.Value = $iKg
            _IEAction($oStockKg, "Click")
            EndIf
            $sStockGram = $oTds(4).FirstElementChild.getAttribute("id", 2)
            $oStockGram = _IEGetObjById($oIE, $sStockGram)
            If IsObj($oStockGram) Then
               $oStockGram.Value = $iGram
               _IEAction($oStockGram, "Click")
               EndIf
        EndIf
    Next
 $btnnext = _IEGetObjById($oIE,"btnnext")
_IEAction($btnnext,"click")
EndIf
EndIf
Exit

But i want to check every input box and fill the only empty inputbox like sugar and oil, and skip wheat and Toor Dal. Becuase they have already text.

fps autoit help.jpg

Share this post


Link to post
Share on other sites

I'm not going to rewrite your script however I can give you direction

If I'm reading this script right you are only looking for blank fields on your first IF statement (line 10). Instead, read all the fields and then search the collection for blank fields. 

Share this post


Link to post
Share on other sites

I think this solution fits better your intentions :

If IsObj($oStockKg) Then
  if $oStockKg.Value <> "" then ContinueLoop  ;  <======== add this line
  $oStockKg.Value = $iKg
  _IEAction($oStockKg, "Click")
EndIf

 

Share this post


Link to post
Share on other sites

@Nine error in line 29.

My code is : 

#include <IE.au3>

Func Quit()
    Exit
 EndFunc
$oIE = _IEAttach ("Home")
_IELoadWait($oIE)

Local $oStockKg = _IEGetObjById($oIE, "txtbuyingstockinkg0")
If IsObj($oStockKg) And StringStripWS($oStockKg.Value, 8) = "" Then
Local $iOutStanding, $iKg, $iGram, $oStockKg, $oStockGram, $sStockKg, $sStockGram
Local $oTds, $oTrs = _IETagNameGetCollection($oIE, "tr")
If IsObj($oTrs) Then
    For $i = 1 To $oTrs.Length
        $oTr = $oTrs($i)
        $oTds = _IETagNameGetCollection($oTr, "td")
        If IsObj($oTds) And $oTds.Length = 5 Then
            $iOutStanding = $oTds(1).InnerText
            $iKg = StringLeft($iOutStanding, StringInStr($iOutStanding, ".")-1)
            $iGram = StringTrimLeft($iOutStanding, StringInStr($iOutStanding, "."))
            $sStockKg = $oTds(3).FirstElementChild.getAttribute("id", 2)
            $oStockKg = _IEGetObjById($oIE, $sStockKg)
            If IsObj($oStockKg) Then
            If $oStockKg.Value <> "" then ContinueLoop  ;  <======== add this line
            $oStockKg.Value = $iKg
            _IEAction($oStockKg, "Click")
            EndIf
            EndIf
            $sStockGram = $oTds(4).FirstElementChild.getAttribute("id", 2)
            $oStockGram = _IEGetObjById($oIE, $sStockGram)
            If IsObj($oStockGram) Then
               $oStockGram.Value = $iGram
               _IEAction($oStockGram, "Click")
               EndIf
    Next
EndIf
EndIf

errpr.JPG

Edited by Nareshm
adding code

Share this post


Link to post
Share on other sites

@Nine Thank you, working perfect, its my mistake because i added two time endif in line 27.

but i need little more help, i want to check all outstanding amount if outstanding amount value of all scheme are 0.000 then i want click on new bill then exit script.

I tried with this code :

Local $oTds = _IETagNameGetCollection($oIE, "td")
For $oTd In $oTds
If $oTd.InnerText = "0.000" Then
_IEAction(_IEGetObjById($oIE,"lnkbill"),"click")
Exit
endIf
Next

But it was checking only one scheme.

*sorry for my bad english.* 

Edited by Nareshm
for adding _IEAction line in script

Share this post


Link to post
Share on other sites
Local $bFound = False, $oTds = _IETagNameGetCollection($oIE, "td")
For $oTd In $oTds
  $bFound = Number($oTd.InnerText) <> 0
Next
If not $bFound then
  _IEAction(_IEGetObjById($oIE,"lnkbill"),"click")
  Exit
endif

Try this (untested ofc)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...