oemript Posted June 26, 2019 Share Posted June 26, 2019 (edited) Referring to following link and image, I would like to know on how to click "Export" and save file into "C:\folder\abc.csv" using AutoIT. Does anyone have any suggestions? Thanks in advance for any suggestions https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal Edited June 26, 2019 by oemript Link to comment Share on other sites More sharing options...
Exit Posted June 26, 2019 Share Posted June 26, 2019 And what have you tried so far? Show us your script. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
oemript Posted June 28, 2019 Author Share Posted June 28, 2019 (edited) Referring to following coding, I would like to know on how to click Export button properly, I try following code without luck. #include <IE.au3> While ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd Global $sFileSavePath = "C:\Download" ;~ Folder Path to Save Excel Documents Global $oIE = _IECreate("https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal") Sleep(10000) ;~ Wait while page loads $oDivs = $oIE.Document.getElementByID('financials') For $oDiv In $oDivs If $oDiv.className = "large_button" Then _IEAction($oDiv, "click") ExitLoop EndIf Next Do you have any suggestions? Thank you very much for any suggestions (^v^) Edited June 28, 2019 by oemript Link to comment Share on other sites More sharing options...
siva1612 Posted June 28, 2019 Share Posted June 28, 2019 Looking from the source code of the webpage, you just have to call the javascript. Like this #include <IE.au3> While ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd Global $sFileSavePath = "F:\Documents" ;~ Folder Path to Save Excel Documents Global $oIE = _IECreate("https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal") _IENavigate($oIE, "javascript:exportKeyStat2CSV()") This will open the save as popup. May be you can build from there. Link to comment Share on other sites More sharing options...
oemript Posted June 28, 2019 Author Share Posted June 28, 2019 (edited) I would like to know on how to click save into default User's download or (specific folder "F:\documents" if possible) folder using AutoIT. Do you have any suggestions? Thank you very much for any suggestions (^v^) Edited June 28, 2019 by oemript Link to comment Share on other sites More sharing options...
siva1612 Posted June 28, 2019 Share Posted June 28, 2019 A simple Google search will give you the way for that. Anyway here it goes #include <IE.au3> While ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd Global $sFileSavePath = "F:\Documents" ;~ Folder Path to Save Excel Documents Global $oIE = _IECreate("https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal") _IENavigate($oIE, "javascript:exportKeyStat2CSV()") Local $hIE = WinGetHandle("[Class:IEFrame]") Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]") WinActivate($hIE) ControlSend($hIE ,"",$hCtrl,"{F6}") ControlSend($hIE ,"",$hCtrl,"{TAB}") ; To Save to default folder ControlSend($hIE ,"",$hCtrl,"{ENTER}") ; To open save as dialog box ;~ Sleep(500) ;~ Send("{DOWN 2}") ;~ Send("{ENTER}") ;~ WinWaitActive("Save As") ;~ Send($sFileSavePath & "\abc.csv") ;~ Send("{ENTER}") Link to comment Share on other sites More sharing options...
oemript Posted June 28, 2019 Author Share Posted June 28, 2019 I would like to know on what wrong Case 2 is, that is not able to save into F:\Documents Folder, and save into User's Download Folder instead. ; Case 1 ; Save to User's Download Folder with no problem Send("{DOWN 1}") Send("{ENTER}") ; Case 2 ; Not able to save into F:\Documents Folder, and save into User's Download Folder instead Send("{DOWN 2}") Send("{ENTER}") WinWaitActive("Save As") Send($sFileSavePath & "\abc.csv") Send($sFileSavePath & "\abc.csv") Send("{ENTER}") Do you have any suggestions? Thank you very much for any suggestions (^v^) Link to comment Share on other sites More sharing options...
siva1612 Posted June 28, 2019 Share Posted June 28, 2019 (edited) Based on the information provided in the above post, I can only say that including the sleep command, as in my post, may help. The sleep command has to be before the Send("{DOWN 2}" ) command. May be if I see the whole script, I can help you further. Also, why do you have the Send($sFileSavePath & "\abc.csv") command twice? Edited June 28, 2019 by siva1612 Link to comment Share on other sites More sharing options...
oemript Posted June 28, 2019 Author Share Posted June 28, 2019 (edited) It seems that can only save under last saved directory, and not able to change the saved filename as well. Do you have any suggestions? Thank you very much for any suggestions (^v^) #include <IE.au3> While ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd Global $sFileSavePath = "F:\Documents" ;~ Folder Path to Save Excel Documents Global $oIE = _IECreate("https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal") _IENavigate($oIE, "javascript:exportKeyStat2CSV()") Local $hIE = WinGetHandle("[Class:IEFrame]") Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]") WinActivate($hIE) ControlSend($hIE ,"",$hCtrl,"{F6}") ControlSend($hIE ,"",$hCtrl,"{TAB}") ; To Save to default folder ControlSend($hIE ,"",$hCtrl,"{ENTER}") ; To open save as dialog box Sleep(500) Send("{DOWN 2}") Send("{ENTER}") WinWaitActive("Save As") Send($sFileSavePath & "\abc.csv") Send("{ENTER}") Edited June 28, 2019 by oemript Link to comment Share on other sites More sharing options...
siva1612 Posted June 28, 2019 Share Posted June 28, 2019 I had given two options in my script to indicate the different possibilities. If you wish to save to a directory other than the default, then the first options has to be commented out. Apologies if In wasn't clear. your code should be #include <IE.au3> While ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd Global $sFileSavePath = "F:\Documents" ;~ Folder Path to Save Excel Documents Global $oIE = _IECreate("https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal") _IENavigate($oIE, "javascript:exportKeyStat2CSV()") Local $hIE = WinGetHandle("[Class:IEFrame]") Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]") WinActivate($hIE) ControlSend($hIE ,"",$hCtrl,"{F6}") ControlSend($hIE ,"",$hCtrl,"{TAB}") ; To open save as dialog box Sleep(500) Send("{DOWN 2}") Send("{ENTER}") WinWaitActive("Save As") Send($sFileSavePath & "\abc.csv") Send("{ENTER}") oemript 1 Link to comment Share on other sites More sharing options...
oemript Posted June 28, 2019 Author Share Posted June 28, 2019 (edited) It seems that AutoIT cannot change last save directory on my PC, I would like to know on whether you can save under F:\Documents directory on your PC or not. If it is the limitation of AutoIT, maybe it is OK to save under User's download folder. Do you have any suggestions? Thank you very much for any suggestions (^v^) Edited June 28, 2019 by oemript Link to comment Share on other sites More sharing options...
siva1612 Posted June 28, 2019 Share Posted June 28, 2019 It does not matter what is the default folder that appears on the Save As dialog box . As long you provide the entire file name with the full path in the filename textbox, it will work i.e. If you provide "F:/Documents/abc.csv" as the file name, even if the active folder in the dialog box is this "John" folder, the file will be saved in the correct location. Link to comment Share on other sites More sharing options...
oemript Posted June 28, 2019 Author Share Posted June 28, 2019 I would like to know on why it pauses and pops up save as dialog box as shown on previous post, Do I need following statement? WinWaitActive("Save As") = Pauses execution of the script until the requested window is active. Do you have any suggestions? Thank you very much for any suggestions (^v^) Link to comment Share on other sites More sharing options...
oemript Posted June 29, 2019 Author Share Posted June 29, 2019 (edited) Del Edited June 30, 2019 by oemript Link to comment Share on other sites More sharing options...
oemript Posted June 30, 2019 Author Share Posted June 30, 2019 (edited) I would like to know on how to select "Descending" option. Do you have any suggestions? Thank you very much for any suggestions (^v^) Edited June 30, 2019 by oemript Link to comment Share on other sites More sharing options...
siva1612 Posted June 30, 2019 Share Posted June 30, 2019 U have to run the below code. But you may need to use a sleep after this statement before exporting _IENavigate($oIE, "javascript:orderChange('desc','Descending')") oemript 1 Link to comment Share on other sites More sharing options...
oemript Posted July 5, 2019 Author Share Posted July 5, 2019 (edited) Thank you very much for suggestions (^v^) Edited July 5, 2019 by oemript Link to comment Share on other sites More sharing options...
oemript Posted July 6, 2019 Author Share Posted July 6, 2019 (edited) Referring to following image, I would like to know on how to retrieve the class name under id="star_span" into variable Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited July 6, 2019 by oemript 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