Jump to content

Windows Open file dialog, How to wait for folder read lag


Recommended Posts

Hi folks

Need 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.

 

regards

Rishav

 

ps. ok so it isn't over 9000 level, but its hard for me, dammit. T_T

Edited by Melba23
Removed image
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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 :D...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

try

ControlSend("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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Excel? Maybe it's just a question of quotes :D...

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 by KaFu
Link to comment
Share on other sites

... 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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...