Jump to content

Recommended Posts

Posted

Hi, 

i am reading autoit forums for about 8 years now and always found a nice solution already.

Now it's time to write a new posts cause i didnt found a proper solution for my problem after spending some hours at google.

 

i'm trying to automate inputs into a form on a website.

i am using ie.au3 UDF and i managed to fill all my values into the left "first" form box.

on the site i am accessing it got exactly the same form box on the right side.

The names of the fields are exactly the same, they are just located in a different "div".

<form class="form-horizontal" id="first-form" role="form">

                    <input type="hidden" name="first_id" id="first_id_id" value="87">


                    <div id="right-amount-div" class="form-group">
                        <label for="inputAmount" class="col-sm-2 control-label">Amount</label>
                        <div class="col-sm-6">
                            <div class="input-group">
                                <input type="text" class="form-control" id="inputAmount" name="inputAmount" placeholder="0.00">
                                <div class="input-group-addon">XPX</div>
                            </div>
                        </div>
                    </div>    

i want to fill the textbox of "inputAmount" in "first-form" and "second-form" - all except that is absolutely the same.

 

i am using this to fill the left side:

$oObj = _IEGetObjByID($oIE,"inputAmount")

_IEAction($oObj,"focus")
Send($amount)

i am using the "send" function, cause i can change the text inside the field but it wouldnt be used by the script running in the website (thats not the problem right now).

 

could anyone point me how i get the second "inputAmount" field?

i'm out of ideas ..

 

i would apreciate your help!

Thanks in Advance, Astralhead

Posted (edited)

You can use my signature...xpath like //input[@id='inputAmount']

Also, don't use send(), use _IEFormElementSetValue, then you don't need to focus, and it's much more reliable.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted
  On 12/21/2017 at 8:38 PM, jdelaney said:

You can use my signature...xpath like //input[@id='inputAmount']

Also, don't use send(), use _IEFormElementSetValue, then you don't need to focus, and it's much more reliable.

Expand  

hi, thanks for your reply!

 

i dont see any signature below your post. You realized i got 2x the "inputAmount" value?

my script will always take the first box then and i need the second one as well.

 

_IEFormElementSetValue works like a charm, the enteres numbers are being greyed out like in an inactive field and not used for calculations.

thats why i used the dirty way with send - i dont really like this one as well.

 

Could you go in detail some more on your solution? -->    //input[@id='inputAmount']

 

Thank you :)

 

Posted
  On 12/21/2017 at 9:38 PM, Danp2 said:

He likely ran into issues using _IEFormElementSetValue not triggering the underlying events, so the site didn't recognize that the value had changed. This is why I wanted to know the URL so that we could take a look and see what was occurring.

Expand  

the site i am working on is an exchange platform.

i want to "sell" some of my havings when special events occure .. 

 

its coinexchange.io website example link would be this: https://www.coinexchange.io/market/DASH/BTC

i need to fill fields Amount and price.

as well hit the right button "submit" - all on the left side is no problem at all so far :)

 

Thanks for your time!

Posted
  On 12/21/2017 at 9:43 PM, Astralhead said:

its coinexchange.io website example link would be this: https://www.coinexchange.io/market/DASH/BTC

Expand  

Here's one way to do it using Javascript --

#include <IE.au3>

$oIE = _IEAttach("coinexchange.io", "url")

Local $oDocument = _IEDocGetObj($oIE)
Local $oWindow = $oDocument.ParentWindow

$oWindow.setTimeout("document.body.JSeval = eval; ", 0) ; a reference to the eval method

Sleep(2000) ; give a little time to the browser to create above variables within the javascript environment.

$JSeval = $oIE.Document.body.JSeval ; a reference to the eval javascript method from within AutoIt

$JSeval('$("form#buy-form input#inputAmount")[0].value = 10')
$JSeval('$("form#buy-form input#inputPrice")[0].value = 25')
$JSeval('updateBuyOrderForm()')

$JSeval('$("form#sell-form input#inputAmount")[0].value = 25')
$JSeval('$("form#sell-form input#inputPrice")[0].value = 10')
$JSeval('updateSellOrderForm()')

 

Posted
  On 12/21/2017 at 10:33 PM, Danp2 said:

Here's one way to do it using Javascript --

#include <IE.au3>

$oIE = _IEAttach("coinexchange.io", "url")

Local $oDocument = _IEDocGetObj($oIE)
Local $oWindow = $oDocument.ParentWindow

$oWindow.setTimeout("document.body.JSeval = eval; ", 0) ; a reference to the eval method

Sleep(2000) ; give a little time to the browser to create above variables within the javascript environment.

$JSeval = $oIE.Document.body.JSeval ; a reference to the eval javascript method from within AutoIt

$JSeval('$("form#buy-form input#inputAmount")[0].value = 10')
$JSeval('$("form#buy-form input#inputPrice")[0].value = 25')
$JSeval('updateBuyOrderForm()')

$JSeval('$("form#sell-form input#inputAmount")[0].value = 25')
$JSeval('$("form#sell-form input#inputPrice")[0].value = 10')
$JSeval('updateSellOrderForm()')

 

Expand  

Wow thats what i call a crazy nice solution!

had no time to test it yet but this looks great :)

 

is there any docu about usage of those commands?

where can i find what i may use for $Jseval = $oIE.XXXXXX.YYYYY.JSeval ?

i'll try to check this solution tomorrow - christmas time - lots of things to do with the family :)

 

Thanks so much!

Astralhead

Posted (edited)
  On 12/21/2017 at 11:36 PM, Danp2 said:

Suggest that you review this thread. You'll run the first portion once to get the $JSeval established. After that, you can pretty much execute any javascript code.

Expand  

hi Danp2,

found the time to try it and it really works great!

i read the whole script but i still dont know how and where i can find the way to use new commands.

The thread you mentioned didnt help me on that as well as your code.

i understand what it does and could enhance it to use on a different input box.

but how do i know the syntax?

how to click my submit button?

 

i tried it like this but really nothing happens - not even an error message.

$JSeval('$("form#sell-form input#sell-order-submit").click')

or 

$JSeval('$("form#sell-form input#sell-order-submit").click()')

 

if there is some kind of documentation for it rather than the thread you linked me it would be very helpful :)

i dont mind reading manuals a lot (i did for the last years in autoit help examples).

 

or is this simply the syntax of java (that i dont know)? :)

 

Greetings - Astralhead

Edited by Astralhead
forgot something
Posted
  On 12/22/2017 at 6:17 PM, Astralhead said:

hi Danp2,

found the time to try it and it really works great!

i read the whole script but i still dont know how and where i can find the way to use new commands.

The thread you mentioned didnt help me on that as well as your code.

i understand what it does and could enhance it to use on a different input box.

but how do i know the syntax?

how to click my submit button?

 

i tried it like this but really nothing happens - not even an error message.

$JSeval('$("form#sell-form input#sell-order-submit").click')

or 

$JSeval('$("form#sell-form input#sell-order-submit").click()')

 

if there is some kind of documentation for it rather than the thread you linked me it would be very helpful :)

i dont mind reading manuals a lot (i did for the last years in autoit help examples).

 

or is this simply the syntax of java (that i dont know)? :)

 

Greetings - Astralhead

Expand  

nevermind - i solved it!

 

$JSeval('$("form#sell-form button#sell-order-submit").click()')

 

its not an "input" its a "button" :)

 

thank you so much for this hint!!!

 

Astralhead

Posted

@Astralhead Maybe you will find what you need here:

 

 

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...