Astralhead Posted December 21, 2017 Share Posted December 21, 2017 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 Link to comment Share on other sites More sharing options...
Danp2 Posted December 21, 2017 Share Posted December 21, 2017 Have you tried using the combination of _IEFormGetCollection and _IEFormGetObjByName? Are you able to share the site's URL? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jdelaney Posted December 21, 2017 Share Posted December 21, 2017 (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 December 21, 2017 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. Link to comment Share on other sites More sharing options...
Danp2 Posted December 21, 2017 Share Posted December 21, 2017 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Astralhead Posted December 21, 2017 Author Share Posted December 21, 2017 59 minutes ago, 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. 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 Link to comment Share on other sites More sharing options...
Astralhead Posted December 21, 2017 Author Share Posted December 21, 2017 3 minutes ago, 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. 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! Link to comment Share on other sites More sharing options...
Danp2 Posted December 21, 2017 Share Posted December 21, 2017 48 minutes ago, Astralhead said: its coinexchange.io website example link would be this: https://www.coinexchange.io/market/DASH/BTC 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()') Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Astralhead Posted December 21, 2017 Author Share Posted December 21, 2017 55 minutes ago, 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()') 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 Link to comment Share on other sites More sharing options...
Danp2 Posted December 21, 2017 Share Posted December 21, 2017 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Astralhead Posted December 22, 2017 Author Share Posted December 22, 2017 (edited) 18 hours ago, 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. 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 December 22, 2017 by Astralhead forgot something Link to comment Share on other sites More sharing options...
Astralhead Posted December 22, 2017 Author Share Posted December 22, 2017 19 minutes ago, 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 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 Danp2 1 Link to comment Share on other sites More sharing options...
Danp2 Posted December 22, 2017 Share Posted December 22, 2017 You should read up on the available selectors. Here's a link to a site with some basic info -- https://www.w3schools.com/cssref/css_selectors.asp Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted December 22, 2017 Share Posted December 22, 2017 @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 Code * 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 * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * 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 * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX 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) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * 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 *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "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" , 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: 2023-04-24 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now