No internet connection
  1. Home
  2. Support

Navigate To Folder of Current Session Monterey Bug

By Matt Friedman @Matt_Friedman
    2022-05-05 03:41:07.373Z

    This script which is now part of SF (Navigate to Folder of Current Session) is broken in Monterey Open/Save dialogs.

    Monterey has a different navigator than previous OS's when you type a / slash in any Open/Save dialog.

    The following code does not work in Monterey

    //Wait for the sheet to appear
    var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
    
    //Set the value of the combo box
    sheet.comboBoxes.first.value.value = path;
    
    //Press OK
    sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
    

    It could be rewritten like this, but if you guys have a better understanding of the new dialog in Monterey, please show us the way!

    //Wait for the sheet to appear
    var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
     
    //Set the value of the combo box
    if (sheet.comboBoxes.first.exists) {
        // For OS prior to Monterey
        sheet.comboBoxes.first.value.value = path;
        sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
    } else {
        // For Monterey or later
        sheet.textFields.whoseValue.is("/").first.value.value = path;
        sf.keyboard.press({keys: "numpad enter"});
    }
    
    • 3 replies
    1. Andrew Scheps @Andrew_Scheps
        2022-05-05 08:50:23.743Z

        That's the right way to do it. In Monterey they changed the combo box to a text field. The only other thing I would do is change the pre-Monterey code to also type Enter instead of clicking the "Go" button. This will ensure it will work on non-English operating systems where that button isn't labelled "Go"

        1. MMatt Friedman @Matt_Friedman
            2022-05-06 00:38:33.011Z

            Thanks for the reply Andrew!

            So updated my code would look more like:

            //Wait for the sheet to appear
            var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
             
            //Set the value of the combo box
            if (sheet.comboBoxes.first.exists) {
                //For OS prior to Monterey
                sheet.comboBoxes.first.value.value = path;
            } else {
                //For Monterey or later
                sheet.textFields.whoseValue.is("/").first.value.value = path;
            }
            
            //Press OK
            sf.keyboard.press({keys: "numpad enter"});
            
            1. Andrew Scheps @Andrew_Scheps
                2022-05-06 11:09:28.566Z

                That should work