Rishav Posted March 27, 2009 Posted March 27, 2009 (edited) Hi folksNeed some more advice. I have the Windows File Open Dialog in which I need to navigate to a folder and select a file. I have the following script take care of it ControlSend("Open", "File &name:","[CLASS:Edit; INSTANCE:1]", $FolderPath) ControlClick("Open","&Open","[CLASS:Button; INSTANCE:2]") Sleep(5000) ControlSend("Open", "File &name:","[CLASS:Edit; INSTANCE:1]",$FileName) Now when I have put in the folder path and click "Open" windows freezes for a few seconds as wexplorer tries to read the folder contents. Usually its instantaneous. Sometimes it is a few seconds.I believe it may depend on the types of files in the folder, their sizes, their numbers, network address etc.What it means is that there is no reliable way for me to discern how much time Wexplorer will take to read that folder and display the file list.If I send the file name before it has refreshed the folder, it will simply be unable to find the file.Any ideas how can I pause the script (something like winwait) till wexplorer is done getting the folder info? Currently I am using SLeep but I have to give a huge sleep time of 5 sec to accomodate all the possible delays that the script may have to suffer. regardsRishav ps. ok so it isn't over 9000 level, but its hard for me, dammit. T_T Edited August 17, 2015 by Melba23 Removed image
SpookMeister Posted March 27, 2009 Posted March 27, 2009 I'm not going to pretend I know what is involved in the direction you are going... but have you looked at the autoit options for doing this instead? FileOpenDialog FileSelectFolder [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
KaFu Posted March 27, 2009 Posted March 27, 2009 If it's a standard windows dialog, this should work: ControlSend("Open", "File &name:","[CLASS:Edit; INSTANCE:1]", $FolderPath & "\" & $FileName) ControlClick("Open","&Open","[CLASS:Button; INSTANCE:2]") Otherwise you'll have to tell us which program it is to check the behavior ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Rishav Posted March 28, 2009 Author Posted March 28, 2009 Thanks SPookie but I am using the file open window from my company's app. Kafu, its a normal windows browse window. The problem with giving both path and file name together is that it will not read the file and just copy the file path. eg. I need to open an excel. if i manually select an excel (or give folder path and filename separately), the file details will be captured and showed in another field in the app. If I just put in the filepath, the file details don't come.
herewasplato Posted March 28, 2009 Posted March 28, 2009 (edited) tryControlSend("Open", "File &name:", "[CLASS:Edit; INSTANCE:1]", $FolderPath) ControlClick("Open", "&Open", "[CLASS:Button; INSTANCE:2]") Do Sleep(9) Until ControlCommand("Open", "&Open", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") ControlSend("Open", "File &name:", "[CLASS:Edit; INSTANCE:1]", $FileName) Edited March 28, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
KaFu Posted March 28, 2009 Posted March 28, 2009 (edited) Excel? Maybe it's just a question of quotes ... Check (sry, don't have excel installed on this box) ControlSend('Open', 'File &name:','[CLASS:Edit; INSTANCE:1]', '"' & $FolderPath & '\' & $FileName & '"') ControlClick('Open','&Open','[CLASS:Button; INSTANCE:2]') Edited March 28, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Rishav Posted March 28, 2009 Author Posted March 28, 2009 thanks both you. Plato, I didn't realize that during refresh the field got disabled. Thanks for that. It works now properly. Thanks for your help too Kafu.
herewasplato Posted March 29, 2009 Posted March 29, 2009 (edited) ... Plato, I didn't realize that during refresh the field got disabled. ...You are welcome - glad that it works for you.The field might be disabled too, but the code that I posted checks the button named "Open". Edited March 29, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
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