CINFINDan Posted June 7, 2007 Share Posted June 7, 2007 I have the following code in a script to respond to a file download dialogue: WinWait("File Download","Do you want to open ") If Not WinActive("File Download","Do you want to open ") Then WinActivate("File Download","Do you want to open ") WinWaitActive("File Download","Do you want to open ") ;MouseMove(161,18) ;MouseDown("left") ;MouseUp("left") Send("+{TAB}s") I have the mouse movement commands commented out because I am trying to use write this script so it is not mouse and pixel (screen resolution) dependent. When the standard internet explorer dialogue appears the focus moves to the Save button on the screen but the Save button does not get activated as it should. I have tried s, {SPACE}, {ENTER} after the {TAB} and the dialogue does not respond. Do I need to use the mouse movements or is there something else I am missing here? Thanks. Dan Link to comment Share on other sites More sharing options...
Zedna Posted June 7, 2007 Share Posted June 7, 2007 Much better is to use ControlSend() or ControlClick() Something like this: ControlClick("File Download","Do you want to open ","Button2") Use "C:\Program Files\AutoIt3\au3info.exe" to view what names have controls in your window. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
CINFINDan Posted June 8, 2007 Author Share Posted June 8, 2007 I have tried ControlSend, ControlClick and none of them seem to work on the Save button. 4424 is the ID of the Save button. By default the Cancel button is in focus when the window is first displayed. When I tried to use the ControlSend command that is commented out below even though 4424 is the ID of the Save button it pressed enter on the Cancel button. Since I knew the dialogue was responding to ControlSend I tried to execute the uncommented ControlSend line below with 2 being the ID of the Cancel button and having it press Shift Tab and Enter. That did move the focus over to the Save button but it did not respond to the Enter command. When the script reaches the last line below which is the window that is supposed to be displayed it just sits there waiting as it should. At that point if I manually press Enter the script continues. Any other help would be appreciated as to why the Save button is not responding to ControlClick or ControlSend. Thank you very much. ControlFocus("File Download","Do you want to open ",2) ;ControlClick("File Download","Do you want to open ",4424) ;ControlSend("File Download","Do you want to open ",4424,"{ENTER}") ControlSend("File Download","Do you want to open ",2,"+{TAB}{ENTER}") WinWait("Save As","Save as &type:") Link to comment Share on other sites More sharing options...
herewasplato Posted June 8, 2007 Share Posted June 8, 2007 I did not see where you had tried ControlFocus on 4424? So, a shot in the dark might be code like this:ControlFocus("File Download", "Do you want to open ", 2) ControlSend("File Download", "Do you want to open ", 2, "+{TAB}") Sleep(500) ControlFocus("File Download", "Do you want to open ", 4424) ControlSend("File Download", "Do you want to open ", 4424, "{ENTER}")You could also check the return of the ControlFocus line. 1 = you win :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
CINFINDan Posted June 8, 2007 Author Share Posted June 8, 2007 It appears that the Sleep(500) was the missing link. Thank you! Link to comment Share on other sites More sharing options...
herewasplato Posted June 8, 2007 Share Posted June 8, 2007 (edited) You are welcome.Sleep statements are not always reliable since the system could get busy at just the wrong moment... but sometimes you have little choice. You could have the next line:WinWait("Save As","Save as &type:") timeout:If Not WinWait("Save As","Save as &type:", 5) Then repeat tab/sleep/enterIt is up to how critcal the script is....enjoy... Edited June 8, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] 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