I already have this command to create Fades:
sf.ui.proTools.appActivate();
sf.ui.proTools.getMenuItem('Edit', 'Fades', 'Create...').elementClick();
var dlg = sf.ui.proTools.windows.whoseTitle.startsWith('Fade').first.elementWaitFor().element;
dlg.buttons.whoseTitle.is('OK').first.elementClick();
However, it does not "click OK" automatically.
But I would like one that extend each clips by 5 Frames on both ends and then apply the fade to the handles length only.
Here's a screenshot of the clip before the command and how it should look like after the command:
Maybe even add another function that first that would 1) Trim the Clip to Selection, then 2) create the handles with Fades.
Thank you!!

Linked from:
- Christian Scheuer @chrscheuer2019-04-11 12:10:46.348Z
Thanks for posting, @Ugosound.
For the clicking OK in your fade dialog, you need to make sure you wait for the right dialog. In your script, you're waiting for a window to pop up, whose title starts with "Fade". But in reality the window that pops up is called "Batch Fades", so that's the title you need to wait on:
sf.ui.proTools.appActivate(); sf.ui.proTools.getMenuItem('Edit', 'Fades', 'Create...').elementClick(); var dlg = sf.ui.proTools.windows.whoseTitle.startsWith('Batch Fades').first.elementWaitFor().element; dlg.buttons.whoseTitle.is('OK').first.elementClick();
- In reply toUgosound⬆:Christian Scheuer @chrscheuer2019-04-11 12:15:57.073Z
There are many ways to create fades on both sides of a clip in PT.
One option (A) is to:
- Extend the clip by 5 frames on both sides
- Invoke the Batch Fades dialog and select a preset with the correct amount of milliseconds set on both sides, then hit OK
Another option (B) is to:
- Invoke the Batch Fades dialog to create fades on both sides
- Use the keyboard to navigate to the first fade, extend it X times with Alt+numpad minus.
- Use the keyboard to navigate to the last fade, extend it X times with Cmd+numpad plus.
IMO option A is better & faster if you can live with having to hard code a millisecond amount that corresponds (almost) to the number of frames needed. Option A also supports if you have loops inside of the selection you're trying to give fades on both sides.
Option B is better if you can live without loop/intra-clip-edit support and that it's generally slower, however it will allow your fades to be frame accurate 5 frames for non 25fps situations where an even ms length for frames is impossible.
I have some code for option A that I'm using here internally. I'd be happy to share if you can put it to some use.
Thank you Christian! @chrscheuer
Yes, it would be great to see the code for option A!
It would probably help me create similar ones as well. Looking forward seeing it!
Also, I corrected the script to Batch Fade and added the "Trim Clip to Selection" Option first:
sf.ui.proTools.appActivate(); sf.ui.proTools.getMenuItem('Edit', 'Trim Clip', 'To Selection').elementClick(); sf.ui.proTools.getMenuItem('Edit', 'Fades', 'Create...').elementClick(); var dlg = sf.ui.proTools.windows.whoseTitle.startsWith('Batch Fades').first.elementWaitFor().element; dlg.buttons.whoseTitle.is('OK').first.elementClick();
That works great, now the clip is being Trimmed first, then applies the fades and closes the window... Just need to add that milliseconds handle extension first!
PS: How do I create that box to copy the script in the way you did there? If I copy and paste, it removes all the colors and makes it less "readable", so I took a screenshot of it, but then it is not possible for someone else to copy and paste it...
Christian Scheuer @chrscheuer2019-04-12 14:03:12.545Z
You use 3 backticks (`) on their own line right after each other to denote start of script (and same after)
Christian Scheuer @chrscheuer2019-04-12 14:04:02.829Z
You can check how I did if you click edit on your original question - I edited it to properly quote the script text :)
Christian Scheuer @chrscheuer2019-04-12 14:08:52.342Z
I do it like this (modified here, original script longer):
function extendSelectionByTwoFramesOnEitherSide() { sf.keyboard.press({ keys: 'alt+shift+numpad minus, alt+shift+numpad minus, cmd+shift+numpad plus, cmd+shift+numpad plus' }); } function trim() { sf.ui.proTools.getMenuItem('Edit', 'Trim Clip', 'To Selection').elementClick(); } function createFade(presetNum) { sf.ui.proTools.getMenuItem('Edit', 'Fades', 'Create...').elementClick(); var win = sf.ui.proTools.windows.whoseTitle.is('Batch Fades').first.elementWaitFor({ timeout: 500 }, 'Could not find Batch Fades window').element; win.buttons.whoseTitle.is('Fade Preset Toggle').allItems[presetNum - 1].elementClick({}, 'Could not click preset button'); win.buttons.getByTitle('OK').elementClick(); } extendSelectionByTwoFramesOnEitherSide(); trim(); createFade(1);
Note I'm using the Batch Fades preset #1 to adjust settings. I've set the settings for Preset 1 like this:
Christian Scheuer @chrscheuer2019-04-12 14:12:35.143Z
I'm using 80 milliseconds here for a film with 25fps framerate (80 ms = 1 / 25 * 1000 * 2) for 2 frames. If you're on 23.976 and would like 5 frames, your milliseconds should be: ( 1 / 23.976 * 1000 * 5 = 208,54 ms ) or just put in 209 ms for a whole number.
You also need to change theextendSelectionByTwoFramesOnEitherSide
function to extend the selection by 5 frames on each side if you want 5 frames.
Note this script requires a nudge setting of 1 frame.Christian Scheuer @chrscheuer2019-04-12 14:40:22.876Z
Here's a longer version of the script that allows you to substitute the frame count for nudging AND that supports verifying to set the nudge value to 1 frame:
function ensureGridIsOneFrame() { var nudgeValueField = sf.ui.proTools.mainWindow.gridNudgeCluster.nudgeControls.nudgeValue.invalidate(); var nudgeValue = (nudgeValueField.value.value + '').trim(); if (nudgeValue.indexOf('+') >= 0) { //Feet+Frames if (nudgeValue != '0+01.00') { nudgeValueField.elementClick(); sf.keyboard.press({ keys: '0, right, 1, right, 0, enter' }); } } else { //Assume timecode if (nudgeValue != '00:00:00:01.00') { sf.ui.proTools.nudgeSet({ value: '00:00:00:01.00' }); } } } function extendSelectionOnEitherSide(frameCount) { ensureGridIsOneFrame(); //You can remove this if it doesn't work for you; optimized for PT2019+ sf.keyboard.press({ keys: 'alt+shift+numpad minus', repetitions: frameCount }); sf.keyboard.press({ keys: 'cmd+shift+numpad plus', repetitions: frameCount }); } function trim() { sf.ui.proTools.getMenuItem('Edit', 'Trim Clip', 'To Selection').elementClick(); } function createFade(presetNum) { sf.ui.proTools.getMenuItem('Edit', 'Fades', 'Create...').elementClick(); var win = sf.ui.proTools.windows.whoseTitle.is('Batch Fades').first.elementWaitFor({ timeout: 500 }, 'Could not find Batch Fades window').element; win.buttons.whoseTitle.is('Fade Preset Toggle').allItems[presetNum - 1].elementClick({}, 'Could not click preset button'); win.buttons.whoseTitle.is('OK').first.elementClick(); } sf.ui.proTools.appActivateMainWindow(); extendSelectionOnEitherSide(2); //Change to 5 for 5 frames trim(); createFade(1); //Change to a different number for a different Batch Fades preset.
- In reply tochrscheuer⬆:BBen Zenium @Ben_Zenium
Amazing Christian - massive shout to you on this script. I changed to Fill Selection and was away. Awesome work, man!
- In reply tochrscheuer⬆:
Jason King @Jason_King
This is awesome! This would save sooo much time editing Atmos's! Are these steps available in Macros?
Christian Scheuer @chrscheuer2022-07-11 00:20:10.732Z
No, but you can just create a script and copy paste this into the script. That script can then be used inside other macros by just dragging and dropping it into a macro.
Jason King @Jason_King
I need to learn how to paste scripts 😆
Christian Scheuer @chrscheuer2022-07-11 02:13:13.463Z
Click "+ New", choose "Script", give it a name, copy the code from above as text, just hit Cmd+V in the script editor inside SF.
Jason King @Jason_King
So it all can go in 1 line?
- In reply tochrscheuer⬆:
Jason King @Jason_King
Ok @chrscheuer just had a chance to try this but it doesn't work for me. I can see it extending the selection out to frames but the actual region isn't extended. Only the selection.
Ok wait I see what it's doing. Can this be altered to extend already trimmed clips. Just say you edit an entire TV/Film with Atmospheres and each clip is on the cut of a new environment. You want to;
- Extend (already edited) the clips by x frames along a whole timeline.
- Batch Fade with preset x
Christian Scheuer @chrscheuer2022-07-11 04:55:53.101Z
Yea but probably better to start as a new thread :)
Jason King @Jason_King
Copy that @chrscheuer but it looks to me the OP was asking the exact same thing?
"But I would like one that extend each clips by 5 Frames on both ends and then apply the fade to the handles length only."
Christian Scheuer @chrscheuer2022-07-11 05:15:03.647Z
True but this thread has already been marked as solved years ago so you may not get as many responses here. I'm on my vacation right now so I won't have time to build it for you right now - it's usually better to not revive old threads that are marked solved as it makes it difficult for people to see which threads need attention. Better to create a new one and link to this.
Jason King @Jason_King
No worries. Enjoy your trip Christian!
New thread here: Extend all clips by 'x' & Batch Fade using Batch Fade preset (whole timeline)
- In reply tochrscheuer⬆:MManne @Manne
Hi! This stopped working on the " win.buttons.whoseTitle.is('Fade Preset Toggle').allItems[presetNum - 1].elementClick({}, 'Could not click preset button');" line. Don't know if it's the new PT version.
Christian Scheuer @chrscheuer2022-11-19 12:44:32.710Z
Yea these have new titles in newer PT versions. I believe @Chris_Shaw was the first to alert me to what they're called now. You should be able to use the UI Picker though to find the reference yourself.
- In reply toManne⬆:MMikko Roisko @Mikko_Roisko
Hi Manne! Did you ever figure out what you need to change in order to get this script to work on latest Pro Tools versions? Would love to use this!
- KIn reply toUgosound⬆:Kenneth Skoglund @Kenneth_Skoglund
New to this, but this script is just what I have been looking for, great!
In my PT version (2019.6) I had to change Trim Clip/To Selection to Trim Clip/To Fill Selection to get it to work.
A question, been trying with not much luck...
If I have automation on the clip, lets say volume. In PT, If I use the trimmer to extend the clip, automation will follow, but not when I trim to fill selection, so when I use this script on clips with automation, it will not follow the extended clip, is there a way to have the automation follow the trim? Or is there another script to add to fix this?
Thanks, KenChristian Scheuer @chrscheuer2020-09-04 11:40:19.147Z
Hi Ken. I didn't see your post here since you replied in a closed thread. Thanks for reminding us.
Generally, it's better to start a new thread and link to the existing thread :)This behavior appears to be a limitation in how the Pro Tools commands you mentioned work.
To automate something, the first step would still be to figure out a sequence of manual commands that could work in Pro Tools. So in this case the only thing I could think of would be positioning the cursor towards the end of the clip, engaging Preview on all parameters on the track, then expanding the selection and finally writing auto to selection. That's just to extend the automation at one end. Then that would need to be coupled with any other sequencing of commands you were already doing.- KKenneth Skoglund @Kenneth_Skoglund
Hi Christian, yeah, not used to this type of forum, its kinda different. My new post was weird also, and I could not delete it.
Thanks. I'll try that, I also tried the script that clears automation on clip edges, might work with some mods, if I can figure out how, :)
Christian Scheuer @chrscheuer2020-09-04 12:05:12.184Z
Sounds good! Happy to help if you get stuck :)
But yea, the first thing is to figure out the manual sequence of commands that need to run, respecting that those cannot be mouse movements across the clips (as SF wouldn't be able to automate that).
- KIn reply toUgosound⬆:Kenneth Skoglund @Kenneth_Skoglund
How do you copy and paste an action in the editor?
- KIn reply toUgosound⬆:Kenneth Skoglund @Kenneth_Skoglund
Since I don't have any plugs in my film at this point, I only need to move volume automation. I figured this will do it for now. It works, if I'm sure I start from the right mode and window focus... I had to use Keyboard strokes, even though I saw on the videos that it's not the greatest. Gonna work on a better solution once I have more time.
sf.ui.proTools.viewCloseFocusedFloatingWindow();
sf.keyboard.press({
keys: "alt+minus",
});
sf.keyboard.press({
keys: "alt+tab, alt+shift+numpad minus, numpad minus, numpad minus, numpad minus",
});
sf.keyboard.press({
keys: "tab, tab, cmd+shift+numpad plus, numpad plus, numpad plus, numpad plus",
});