hey,
so i wanted a simple script just to copy the path of whatever my currently open finder window is and paste that into the pro tools open dialog.
here's what I borrowed from another post regarding this sort of thing:
var folderPath = decodeURIComponent(sf.appleScript.finder.selection.getItem(0).asItem.path);
sf.keyboard.type({ text: folderPath });
sf.wait({ intervalMs: 150 });
sf.keyboard.press({ keys: 'enter' });
and it works ok, but so far has been pretty inconsistent and unreliable. about half the time or less it will work great, but often it will fail and just direct me to the root volumes folder, not what my top level finder window is, or elsewhere. sometimes it tries to paste the full path but doesn't quite finish. and sometimes the command just errors out and doesn't work at all. haven't figured out any rhyme or reason to when it is successful and when its not.
is there perhaps a better or more refined script to do something basic like this? or are finder commands still a little buggy?
let me know if there is more info I can provide. thx!
SF4.4, pts 2018.7, macOS 10.12
my normal steps are:
-
have desired location loaded as top window in finder
-
import session data, import video, import audio etc etc in pro tools
-
invoke script
- Christian Scheuer @chrscheuer2018-09-12 14:50:19.974Z
Hi @SeanH. Yea that's a great idea for a script, I think it would work well as part of the session management package. I'll take a look, I know we have some more stable code handling open/save dialogs somewhere, just need to dig it out.
- ?@anon6770933309
The ability to change locations in open/save dialogs would be an awesome addition to SF. Like with Default Folder X.
See attached demo clip. I change the locations via AppleScript and DFX.
Christian Scheuer @chrscheuer2018-09-14 12:37:11.232Z
I completely agree! Also, I think this needs to be core/built-in actions that are natively supported by SF not just scripts we mock together. This could be a core feature
- ?@anon6770933309
Yep! 👍
- In reply toSeanH⬆:Christian Scheuer @chrscheuer2018-09-14 15:27:13.789Z
This will be more stable from beta 4.5, using the following function:
This function will navigate to the folder path specified as the 1st argument in any frontmost application's focused Open/Save dialog.
function navigateTo(path) { //Get a reference to the focused window in the frontmost app: var win = sf.ui.frontmostApp.focusedWindow; //Sanity check - make sure window is either Save or Open dialog if (!(win.title.value.indexOf('Save') >= 0 || win.title.value.indexOf('Open') >= 0)) throw 'Focused window is not an Open or Save dialog. Title: ' + win.title.value; //Open the Go to... sheet sf.keyboard.type({ text: '/' }); //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"'); //Wait for sheet to close win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time'); }
To navigate to the current Pro Tools session's folder:
var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/'); navigateTo(folderPath);
To navigate to the top Finder window's folder:
var folderPath = decodeURIComponent(sf.appleScript.finder.selection.getItem(0).asItem.path); navigateTo(folderPath);
Christian Scheuer @chrscheuer2018-09-14 15:43:36.911Z
- In reply tochrscheuer⬆:
Christian Scheuer @chrscheuer2018-09-14 15:50:00.991Z
These scripts are also published in the Pro Tools Session Management command package.