eibbtoddb Posted June 2, 2014 Share Posted June 2, 2014 I am trying to automate the "clicking" of a button (or link) on a website. I am very new to AutoIt and am not sure how to get this done. When I hover over what looks like a hyperlink, I see this message, "javascript:void(0);" When I view the page source, I see this code: function HandleSubmit(astrValue) { document.getElementById('HiddenFormSubmitted').value = astrValue; document.getElementById('PageForm').submit(); if (astrValue != 'DOWNLOADREPORT' && astrValue != 'DOWNLOADREPORTEXTENDED') { DisableFields(); } } I also found this href in the page source: <a href="javascript:void(0);" onclick="HandleSubmit('DOWNLOADREPORTEXTENDED');return false;" target="_blank" class="UPE-Link"><img src="/shared/assets/legacy/affiliatesweb/engine/images/download.gif" border="0" style="vertical-align:text-top;" /> Download Extended Report</a> I need to submit/click the button/link that submits the 'DOWNLOADREPORTEXTENDED' portion. When I click it on the website, a .csv file is downloaded to to my computer. This is what I need to automate on a daily basis. Thanks in advance for your help! ~Todd Link to comment Share on other sites More sharing options...
Danp2 Posted June 2, 2014 Share Posted June 2, 2014 You didn't specify which browser you are using. For IE, you can use the _IE* functions. Once you have a reference to the IE object, you could do something like this: $oIE.document.parentwindow.execScript("HandleSubmit('DOWNLOADREPORTEXTENDED');") WebDriver UDF [GH&S] Latest version Wiki FAQs Link to comment Share on other sites More sharing options...
eibbtoddb Posted June 3, 2014 Author Share Posted June 3, 2014 Thanks for the reply! Yes, IE for now. Is there any other code I need other than that single line? This is only my 2nd day using AutoIT and I'm not too familiar with all the available functionality. So far, I really like this tool! Link to comment Share on other sites More sharing options...
Palestinian Posted June 3, 2014 Share Posted June 3, 2014 You could look up IE functions in the help file, the help file is the best place for you to start. You could also open the includes folder where you installed AutoIt and then check IE.au3 to learn about its functions and how they work. Link to comment Share on other sites More sharing options...
eibbtoddb Posted June 3, 2014 Author Share Posted June 3, 2014 Nothing happened when I added that line of code to my script.... Anything else I should try or need to add to make that run? Link to comment Share on other sites More sharing options...
Exit Posted June 3, 2014 Share Posted June 3, 2014 (edited) I don't see your code. Would be useful to publish. Edited June 3, 2014 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
eibbtoddb Posted June 3, 2014 Author Share Posted June 3, 2014 This is what I have so far.... #include <IE.au3> $oIE = _IECreate("https://affiliates.upickem.net/net/Welcome.aspx") $UserName = _IEGetObjByName($oIE, "txtUsername") $Password = _IEGetObjByName($oIE, "txtPassword") $BtnLogin = _IEGetObjByName($oIE, "btnLogin") $BtnSearch = _IEGetObjByName($oIE, "cmdSearch") _IEPropertySet($UserName, 'innerText', 'mysusername') _IEPropertySet($Password, 'innerText', 'mypassword') _IEAction ($BtnLogin, "click") _IELoadWait($oIE) $oIE = _IENavigate($oIE, "https://affiliates.upickem.net/Engine/ProfitReport.aspx?contestid=12345") _IELoadWait($oIE) _IEAction ($BtnSearch, "click") _IELoadWait($oIE) $oIE.document.parentwindow.execScript("HandleSubmit('DOWNLOADREPORTEXTENDED');") Link to comment Share on other sites More sharing options...
Exit Posted June 3, 2014 Share Posted June 3, 2014 (edited) $BtnSearch = _IEGetObjByName($oIE, "cmdSearch") --> IE.au3 T3.0-1 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: cmdSearch, Index: 0) Try this: #AutoIt3Wrapper_Run_Debug_Mode=y #include <IE.au3> $oIE = _IECreate("https://affiliates.upickem.net/net/Welcome.aspx") $UserName = _IEGetObjByName($oIE, "txtUsername") $Password = _IEGetObjByName($oIE, "txtPassword") $BtnLogin = _IEGetObjByName($oIE, "btnLogin") _IEPropertySet($UserName, 'innerText', 'mysusername') _IEPropertySet($Password, 'innerText', 'mypassword') _IEAction ($BtnLogin, "click") _IELoadWait($oIE) $oIE = _IENavigate($oIE, "https://affiliates.upickem.net/Engine/ProfitReport.aspx?contestid=12345") _IELoadWait($oIE) $BtnSearch = _IEGetObjByName($oIE, "cmdSearch") _IEAction ($BtnSearch, "click") _IELoadWait($oIE) $oIE.document.parentwindow.execScript("HandleSubmit('DOWNLOADREPORTEXTENDED');") Edited June 3, 2014 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
eibbtoddb Posted June 3, 2014 Author Share Posted June 3, 2014 That search button click is probably not important since this report 'auto-populates' when the page opens. I should move that button click to later in the script because that button actually appears on this page: $oIE = _IENavigate($oIE, "https://affiliates.upickem.net/Engine/ProfitReport.aspx?contestid=12345") Link to comment Share on other sites More sharing options...
Exit Posted June 3, 2014 Share Posted June 3, 2014 Like I edited in my previous post. App: Au3toCmd UDF: _SingleScript() 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