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