jrwauto Posted July 7, 2011 Share Posted July 7, 2011 I am trying to automate saving a file in IE9. In IE8 it was no prob, the popup was in a window called File Download, now in IE9 it's in this weird (non-modal) pesudo-window that seems to be part of the IE window (I attached a png. The brown square is for anonymity). When I use Au3Info and hover over the IE window vs. when I hover over the "Do you want to open or save" pseudo-window at the bottom, the Window info is the same and the only thing that changes is the infor under the Control tab of Au3Info. So at the top, under Basic Window Info, the Class (for both hovering over IE vs. the pseudo-window) is "IEFrame" But under Basic Control Info, the class changes from "Internet Explorer_Server" to "DirectUIHWND" To get the IE's title, this works: ControlGetText("[CLASS:IEFrame; INSTANCE:1]",'','') So I was hoping the pseudo-window would work by incrementing the INSTANCE property, but it does not. What's weird about this, is the function's name is CONTROLGetText, not WINDOWGetText, so I would have expected to use the Control's class name, which (as noted above) is not "IEFrame", but "Internet Explorer_Server" In this way, I was hoping to get ahold of the pseudo-window using ControlGetText("[CLASS:DirectUIHWND; INSTANCE:1]",'','') So is there a way to use the CONTROL's class type instead of the WINDOW's class type? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 8, 2011 Share Posted July 8, 2011 It's an HTML rendered dialogbox. Get a reference to it with _IEAttach() using the "dialogbox" option and treat the "controls" as the HTML DOM elements they are. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jrwauto Posted July 8, 2011 Author Share Posted July 8, 2011 (edited) It's an HTML rendered dialogbox. Get a reference to it with _IEAttach() using the "dialogbox" option and treat the "controls" as the HTML DOM elements they are.Thanks PsaltyDS.The bad news is I'm pretty sure it's not part of the DOM. I could be wrong, but I'm trying to do this with Ruby/Watir and its hooks into AutoIt, so I'm relatively familiar with the DOM. I'm assuming you're saying it's being created by IE. It's definitely not part of the app. When I use IE developer tools and it's "DOM browser" mode and try to get ahold of this popup, it doesn't look like DOM. And when I browser the HTML I don't see it. As I said, I could be wrong, but if it were HTML I'd assume it would come up in the View Page Source or using the DOM browser, etc. If it IS HTML I'd be thrilled, because then I could get at it with Watir very easily... Edited July 8, 2011 by jrwauto Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 8, 2011 Share Posted July 8, 2011 Sorry, my mistake. I was keying off "Internet Explorer_Server" without reading closely enough. I'm afraid DirectUIHWND implies an owner-drawn client area that could have been drawn by any one of several Microsoft products. You might be out of luck as there isn't a publicly documented API for AutoIt to use. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jrwauto Posted July 8, 2011 Author Share Posted July 8, 2011 Sorry, my mistake. I was keying off "Internet Explorer_Server" without reading closely enough. I'm afraid DirectUIHWND implies an owner-drawn client area that could have been drawn by any one of several Microsoft products. You might be out of luck as there isn't a publicly documented API for AutoIt to use.Wow, ok. Well I will pass this info along to people who know more than I do who may be able to find a workaround.Thanks again : ) Link to comment Share on other sites More sharing options...
Tvern Posted July 9, 2011 Share Posted July 9, 2011 This does seem to be able to start the download, but it's likely to fail if someone is using the PC and it can't be done in the background (seems like the IE window has to be active) $hIE = WinGetHandle("[Class:IEFrame]") $hCtrl = ControlGetHandle($hIE,"","[Class:DirectUIHWND]") $aPos = ControlGetPos($hIE,"",$hCtrl) $x = $aPos[2]-160 $y = $aPos[3]-30 ;Use WinActivate($hIE) ;doesn't work in the background ControlClick($hIE,"",$hCtrl,"primary",1,$x,$y) ;this only gives focus to the save button ControlSend($hIE,"",$hCtrl,"{Enter}") ;this does work once the save button is focussed ;Or alternatively: $x += $aPos[0] $y += $aPos[1] WinActivate($hIE) MouseClick("primary", $x, $y, 1, 0) I assume INetGet can not be used because you have to be logged in or something. I can think of two possible workarounds for this: 1. Use an embedded IE window in your own GUI, to log in, then do the download using INetGet, or INetRead. This has worked for me in the past to download bank transactions and seems to work because your process is the parent of the IE window, so the session is valid for both. I've never heard anyone confirm this works for other sites as well though. 2. Avoid the browser all together and use WinHttp for every step. If you want the actions to be visible this can be tricky, but for background downloads this is usually very efficient. Just use a tool to check the httprequests send by your browser and make the script mimic those. An added bonus is that any topic involving WinHttp usually has a response from trancexx before you can refresh the page. Link to comment Share on other sites More sharing options...
jrwauto Posted July 12, 2011 Author Share Posted July 12, 2011 (edited) Tvern, thank you very much. As much as I hate using coordinates, I able to get it to work reliably (thus far) using them. I had to click the down arrow next to Save, send down (instead of Enter) and 'a' for Save As. Also had to put some waits in there because IE wasn't responding fast enough without them. ai.ControlClick(windowTitle, "", "[Class:DirectUIHWND]" , "left", 1, buttonOffsetX, buttonOffsetY) sleep 0.2 ai.ControlSend(windowTitle, "", "[Class:DirectUIHWND]","{Down}") sleep 0.1 ai.ControlSend(windowTitle, "", "[Class:DirectUIHWND]","a") I think my main issue was that I was trying to do ControlClick("[Class:DirectUIHWND]", "", "") when I should have been doing ControlClick(windowTitle, "", "[Class:DirectUIHWND]" It seems clear now, but somehow I got it in my head that the first call was right. Anyway, I'm going to show the solution to the Watir community and see what they think. I'm hoping someone will come up with a 'bulletproof' way of doing this, but this seems to work pretty well. Thanks again, and if I can rep you, let me know how and I'd be happy to do so Edited July 12, 2011 by jrwauto Link to comment Share on other sites More sharing options...
Tvern Posted July 12, 2011 Share Posted July 12, 2011 (edited) I think my main issue was that I was trying to do ControlClick("[Class:DirectUIHWND]", "", "") when I should have been doing ControlClick(windowTitle, "", "[Class:DirectUIHWND]" Actually, both would do pretty much the same, the terms control and window can be a bit confusing as controls are usually child windows of another window. The main reason for using the second syntax is that it makes it a bit easier to double check if you have the right control when there are more than one window open. The main problem is that I think IE deliberately made the control hard to automate as some backwards security measure. To make this as reliable as possible it'd be nice to completely do away with the download through IE. (Look at my last post for suggestions.) Edit: added endquote Edited July 15, 2011 by Tvern Link to comment Share on other sites More sharing options...
jrwauto Posted July 14, 2011 Author Share Posted July 14, 2011 It's an interesting idea. I'm using this in conjunction with Watir to test our front end so I'd like everything to go through the browser if possible. If this proves unreliable I may go the direct http request route as you suggest... Link to comment Share on other sites More sharing options...
ellavader Posted August 12, 2011 Share Posted August 12, 2011 Tvern, thank you very much. As much as I hate using coordinates, I able to get it to work reliably (thus far) using them. I had to click the down arrow next to Save, send down (instead of Enter) and 'a' for Save As. Also had to put some waits in there because IE wasn't responding fast enough without them. ai.ControlClick(windowTitle, "", "[Class:DirectUIHWND]" , "left", 1, buttonOffsetX, buttonOffsetY) sleep 0.2 ai.ControlSend(windowTitle, "", "[Class:DirectUIHWND]","{Down}") sleep 0.1 ai.ControlSend(windowTitle, "", "[Class:DirectUIHWND]","a") jrwauto, how did you figure out to use "a" for Save As? I'm trying to figure out how to close that info bar, and the only way to do that is by clicking on the "x". I am not having any success with how to do that, and I was hoping that there was a way I could reference it? Not sure that "&Close" works and WinClose() doesn't seem to work, unless I"m passing in the incorrect parameters for it. Do you have any helpful suggestions for me? Thanks in advance. Link to comment Share on other sites More sharing options...
alshamma Posted October 24, 2012 Share Posted October 24, 2012 (edited) I need to send an Open to launch a Citrix launch.ica. I took Ellavader's java code and found this works well: Func ClickOpenInIEBar() #cs Credit to Ellavader at http://www.autoitscript.com/forum/topic/127987-handling-ie9-file-download-activex-prompts/ #ce $retWin = WinGetHandle("[Class:IEFrame]", "") $winTitle = "[HANDLE:" & $retWin & "]" ; get a handle to the control (IE9 download info bar) $ctrlHandle = ControlGetHandle($winTitle, "", "[Class:DirectUIHWND]") $ctrlTitle = "[HANDLE:" & $ctrlHandle & "]" ; must have this line in here in order to get a handle to the control WinWaitActive($ctrlTitle, "[CLASS:DirectUIHWND]", 10); $xy = ControlGetPos($winTitle, "", "[Class:DirectUIHWND]"); //will differ depending on size of control $xpos = 730 ; $xy[2] - 160 ; depends on control size $ypos = 25 ; Open Prompt WinActivate($winTitle, "Do you want to open or save"); ControlFocus($winTitle, "Do you want to open or save", "[CLASS:DirectUIHWND]"); ControlClick($winTitle, "", "[Class:DirectUIHWND]", "primary", 1, $xpos, $ypos); //activates the open button ; more magic - must send enter after click!!! ControlSend($winTitle, "", "[Class:DirectUIHWND]", "{ENTER}", 0) EndFunc Edited October 24, 2012 by alshamma 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