Hello! I'm a new SoundFlow user and I love it. One of the scripts I'm working on involves building a lot of sessions from a template using information given to us by our client in Google Sheets. Eventually I'll figure out a system that's intelligent enough to "read" the Google Sheet and do things automatically for me, but for now I'm using keyboard press to navigate around the Google Sheet and copy information into Pro Tools.
The issue I'm having is when I try to copy the name I want into the Save Copy In dialogue. I get an Apple error message when the script goes from focusing on Safari to focusing back on Pro Tools. Command + V is not available for some reason when this happens nor is Edit > Paste from the dropdown menu, but right-click > Paste in the name field are available. Whenever I do either of those, however, for some reason it selects the whole text previously entered and pastes over it. Not sure why? I'm happy with how the script works up to this point. Here's what I have for that part of the script:
//back to Pro Tools
sf.ui.proTools.appActivateMainWindow();
sf.wait({
intervalMs: 2000,
});
sf.ui.proTools.windows.whoseTitle.is("Save").first.textFields.whoseValue.is("CM_1610_pvLC_").first.popupMenuSelect({
isRightClick: true,
menuPath: ['Paste'],
});
sf.wait({
intervalMs: 200,
});
//add underscore
sf.keyboard.type({
text: "_",
});
//back to Google Sheets
sf.ui.app('com.apple.Safari').appActivateMainWindow();
sf.wait({
intervalMs: 200,
});
//move to cue name
sf.keyboard.press({
keys: "right",
});
sf.keyboard.press({
keys: "cmd+c",
});
//back to Pro Tools
sf.ui.proTools.appActivateMainWindow();
sf.wait({
intervalMs: 2000,
});
//paste cue name
sf.ui.proTools.windows.whoseTitle.is("Save").first.textFields.whoseValue.is("CM_1610_pvLC_").first.popupMenuSelect({
isRightClick: true,
menuPath: ['Paste'],
});
//add session name suffix to save copy in
//sf.keyboard.type({
text: "_v1_PREP",
});
- MComment deleted
- TTristan Hoogland @Tristan
Haven't tested this, but the main two issues are you're activating ProTools' main window with the
sf.ui.proTools.appActivateMainWindow();
each time you switch back to the app which takes the focus away from the front most dialog being the save dialog. To mitigate this you just simply activate the app - akasf.ui.proTools.appActivate();
For further insurance you can focus the save dialog by using
elementRaise()
I feel like there might be an opportunity to make your script more robust with settextvalue type stuff, but purely to get you rolling let's just keep with the keypresses (which we should avoid at all costs if possible). Also I'd recommend utilizing menu clicks in Safari to copy the data. Here's an updated script that should get you on your way hopefully!
const safariApp = sf.ui.app('com.apple.Safari'); //back to Pro Tools sf.ui.proTools.appActivate(); //focus save dialog sf.ui.proTools.windows.whoseTitle.is("Save").first.elementRaise(); //paste clipboard text sf.keyboard.press({ keys: "cmd+v", }); //add underscore sf.keyboard.type({ text: "_", }); //back to Google Sheets safariApp.appActivateMainWindow(); //wait for app to become active - probably unnecessary safariApp.appWaitForActive(); //move to cue name sf.keyboard.press({ keys: "right", }); //copy data to clipboard safariApp.menuClick({ menuPath: ["Edit", "Copy"], }); //back to Pro Tools sf.ui.proTools.appActivate(); //focus save dialog sf.ui.proTools.windows.whoseTitle.is("Save").first.elementRaise(); //paste clipboard text sf.keyboard.press({ keys: "cmd+v", }); //add session name suffix to save copy in sf.keyboard.type({ text: "_v1_PREP", });
- MMatias Ambrogi-Torres @Matias_Ambrogi_Torre
Awesome! This worked great, thank you so much! I'll try switching to menu clicking instead of keys commands - thanks for the pointer. And I'll look into settextvalue, I'd never heard of it. Thanks for your help!
- TTristan Hoogland @Tristan
I watched the video too - very swift script! Looks pretty involved. Glad it helps :)