Jump to content

How to fill text box of internet explorer by reading text?


naru
 Share

Recommended Posts

Are you sure you don't need ".450" rather than "450"?  As I don't have access to your page, I'd just be guessing why it's not working, you could try clicking on each item (maybe java event)

$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

 

Link to comment
Share on other sites

1 hour ago, Subz said:

Are you sure you don't need ".450" rather than "450"?  As I don't have access to your page, I'd just be guessing why it's not working, you could try clicking on each item (maybe java event)

$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

 

@Subz i get error on line 33

#include <IE.au3>
HotKeySet("{ESC}", "Quit")

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
Next
 $btnnext = _IEGetObjById($oIE,"btnnext")
_IEAction($btnnext,"click")
EndIf
EndIf

$btnnext = _IEGetObjById($oIE,"btnnext")
_IEAction($btnnext,"click")
_IELoadWait($oIE)
Exit

 

Edited by Nareshm
Link to comment
Share on other sites

Scite tells you exactly what the issue is so fix it, hint your missing Endif, please at least try to resolve issues yourself, as I mentioned I've written the code blind, I do not have anything to test against, you do, so you will need to fix and diagnose as required.

Link to comment
Share on other sites

  • 5 weeks later...

Hello @Subz

I added :

If IsObj($oStockKg) Then
            $oStockKg.Value = $iKg
            _IEAction($oStockKg, "Click")

But Webpage showing same error  "The amount of taking is greater than the remaining quantity." error and then reload page and input box is empty again.

When i enter amount manualy no error showing.

My Whole 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
            $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

 

Link to comment
Share on other sites

  • 7 months later...

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
 Share

  • Recently Browsing   0 members

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