mizotac Posted April 20, 2020 Share Posted April 20, 2020 Hello Folks, I've searched all related posts, maybe spanning 6 years back, and couldn't get around that I'm automating a download button on the enclosed url. The button executes a javascript and uses a session-attached cookie. That's as far as I could get as I'm not into front-end. Bottom line; I couldn't get to download the file another way than GUI automation Now, the below script clicks on download succesfully, even if IE is hidden (to avoid end user interruption). However, I cannot send keystrokes to the open/save control while IE is still hidden. Even if the control takes focus, it won't work unless IE becomes visible again. I added comments for easier perusal. Your help is really appreciated. P.S. I'm fiddling also with SecondDesktop script from here, but still no success expandcollapse popup#include <IE.au3> ; change first 0 to 1 to run IE visible $oIE = _IECreate("https://www.eclaimlink.ae/NoneRegisteredCodingSets.aspx", 1, 0, 0) _IELoadWait($oIE) $myTitle = _IEPropertyGet($oIE, "title") ; Grab Title of IE window Sleep (500) $oIE = _IEAttach($myTitle) $oDiv1 = _IEGetObjById($oIE, "ContentPlaceHolder1_NoneRegisteredCodingSetsUC1_GridView1_btnDownload_10") _IEAction($oDiv1, "click") ; get the handle of main window Local $windHandle= WinGetHandle("[Class:IEFrame]", "") Local $winTitle = "[HANDLE:" & $windHandle & "]" $rtrnFocus = ControlFocus($winTitle,"","DirectUIHWND1" ) ;changes focus to open/save dialoge box control ;MsgBox(1,"",$rtrnFocus); for testing, returns 1 for successful focus control ;_IEAction($oIE, "visible") ; the following send actions only work properly if IE is visible ; It does not matter even if control ClassNameNN is added to ControlSend parameters WinActivate($myTitle) ControlSend($winTitle, "", "", "{F6}") Sleep(500) ControlSend($winTitle, "", "", "{TAB}") Sleep(500) ControlSend($winTitle, "", "", "{Enter}") ;_IEAction($oIE, "invisible") _IEQuit($oIE) Link to comment Share on other sites More sharing options...
Nine Posted April 20, 2020 Share Posted April 20, 2020 One way, not perfect but working : #include <Constants.au3> #include <IE.au3> #include "..\BlockInput\BlockInputEx.au3" ; ;https://www.autoitscript.com/forum/topic/199762-udf-blockinputex/ $oIE = _IECreate("https://www.eclaimlink.ae/NoneRegisteredCodingSets.aspx", 0, 0) $oDiv1 = _IEGetObjById($oIE, "ContentPlaceHolder1_NoneRegisteredCodingSetsUC1_GridView1_btnDownload_10") _IEAction($oDiv1, "click") Sleep (800) Local $hWnd= _IEPropertyGet ($oIE, "hwnd") Local $hCtrl = ControlGetHandle ($hWnd, "", "DirectUIHWND1") ConsoleWrite ("Control = " & $hCtrl & @CRLF) _BlockInput ($BI_DISABLE) $oIE.visible = True Sleep (800) ConsoleWrite (ControlSend ($hWnd, "", $hCtrl, "{F6}{TAB}") & @CRLF) Sleep (800) ControlSend ($hWnd, "", $hCtrl, "{ENTER}") $oIE.visible = False _BlockInput ($BI_ENABLE) Sleep (1000) _IEQuit ($oIE) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mizotac Posted April 20, 2020 Author Share Posted April 20, 2020 Thank you for this neat idea & UDF @Nine It will come handy in other scripts too. It works and IE window shows briefly for 2 seconds. However, when I comment out visible functions (i.e script runs with completely hidden IE till the end), the control does not receive keystrokes and nothing downloaded. My ultimate target is to click on 'Save' and close IE without anything displayed to end user. Could this be achieved some how ? Link to comment Share on other sites More sharing options...
Nine Posted April 20, 2020 Share Posted April 20, 2020 I think this is the closest we can get to hide the download : #include <Constants.au3> #include <IE.au3> #include "..\BlockInput\BlockInputEx.au3" ; ;https://www.autoitscript.com/forum/topic/199762-udf-blockinputex/ $oIE = _IECreate("https://www.eclaimlink.ae/NoneRegisteredCodingSets.aspx", 0, 0) $oDiv1 = _IEGetObjById($oIE, "ContentPlaceHolder1_NoneRegisteredCodingSetsUC1_GridView1_btnDownload_10") _IEAction($oDiv1, "click") Sleep (800) Local $hWnd= _IEPropertyGet ($oIE, "hwnd") Local $hCtrl = ControlGetHandle ($hWnd, "", "DirectUIHWND1") ConsoleWrite ("Control = " & $hCtrl & @CRLF) WinSetTrans ($hWnd, "", 0) _BlockInput ($BI_DISABLE) $oIE.visible = True WinActivate ($hWnd) Sleep (800) ConsoleWrite (ControlSend ($hWnd, "", $hCtrl, "{F6}{TAB}") & @CRLF) Sleep (800) ControlSend ($hWnd, "", $hCtrl, "{ENTER}") $oIE.visible = False _BlockInput ($BI_ENABLE) Sleep (2000) _IEQuit ($oIE) You may need/try to adjust the sleep time... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mizotac Posted April 20, 2020 Author Share Posted April 20, 2020 I was fiddling with WinSetState to minimize IE window, didn't do the trick. Your trick 'WinSetTrans' is more neat and cool. Adjusted sleep time for slower end-user machines. Thank you so much @Nine Problem solved! Link to comment Share on other sites More sharing options...
Nine Posted April 20, 2020 Share Posted April 20, 2020 Edit your thread title to mark it as solved. Glad it is working for you, mizotac 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mizotac Posted April 20, 2020 Author Share Posted April 20, 2020 Thanks again. It seems I cannot edit my original post before I hit 5 posts. Will mark as solved once I have the option activated Link to comment Share on other sites More sharing options...
Nine Posted April 20, 2020 Share Posted April 20, 2020 oh ya true. Just reply to this post “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mizotac Posted April 20, 2020 Author Share Posted April 20, 2020 😉😎 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