Forum Discussion

exdunepilot's avatar
exdunepilot
Contributor
8 years ago

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.

  • HKosova's avatar
    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.

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      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?

      • HKosova's avatar
        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.