Ask a Question

Highlight All Files within a Folder in Standard Windows Open File Dialog

SOLVED
exdunepilot
Contributor

Highlight All Files within a Folder in Standard Windows Open File Dialog

Our application launches a standard windows open file dialog popup.  However, we load ALL the files within a folder so I cannot use TC's OpenFile() method.  Trying to use a combo of namemapped objects & Keys()  is not working reliably.     The biggest problem appears to be trying to use Keys() to type in the path to the directory textfield.  And that Windows object does not have any SetText-style methods.  Any suggestions?

4 REPLIES 4
HKosova
SmartBear Alumni (Retired)

The Open File dialog accepts multiple file names as a space-separated list of quoted items:

"C:\MyFile1.txt" "C:\MyFile2.txt"

OpenFile() sets the dialog's file name input as is, so you can try the following:

// JavaScript/JScript
dlgOpen.OpenFile("\"C:\\MyFile1.txt\" \"C:\\MyFile2.txt\"");

 

Alternatively, you can use the Ctrl+A shortcut to select all files in the Open dialog:

var strFolder = "C:\\MyFolder\\Subfolder\\";
var dlgOpen = ...;
// Navigate to the folder var fileInput = dlgOpen.Window("ComboBoxEx32").FindChild("WndClass", "Edit", 2); fileInput.SetText(strFolder); fileInput.Keys("[Enter]");
// Select all files & open dlgOpen.FindChild("WndClass", "SHELLDLL_DefView", 5).Keys("^a"); dlgOpen.Window("Button", "&Open").Click();

This was tested on Windows 7. Other Windows versions can have different object names for the Open dialog elements, so adjust accordingly.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

@HKosova:

> OpenFile() sets the dialog's file name input as is

Wow, this is not documented - help talks just about single file.

Helen, could you please ask your guys to expand help topic for the OpenFile() method with your piece of advise?

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
HKosova
SmartBear Alumni (Retired)

@AlexKaras, this is really more of a hack / unintended side effect, so I'd rather have the info just here and not in the official docs.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

OK, I see. Thank you, Helen.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: