Alright everyone! I'm so close to figuring this out! I want to create a script that allows me to get "in-between" the small and medium track heights. More explained after the script....
Backstory here, is that I want to use a playlist toggle, to toggle between waveform and playlist modes. Here is the script for that currently...
//Calling command "Track Heights" from package "Track Heights" (installed from user/pkg/version "di7dN0keyHdE1HAif7Qi47Oz53E2/cktudjn8j0000p510z6jbr3mz/ckvqyxwe0000231108n6d5mf6")
sf.soundflow.runCommand({
commandId: 'user:ckxxkr3od0001fe1020g092wz:cktudkfw20002p5109ic73tos',
props: {
trackSize: "medium",
}
});
if (sf.ui.proTools.selectedTrack.invalidate().displaySelectorButton.value.value === "waveform") {
sf.ui.proTools.selectedTrack.trackDisplaySelect({
displayPath: ['playlists']
});
} else {
sf.ui.proTools.selectedTrack.trackDisplaySelect({
displayPath: ['waveform']
});
}
//Calling command "Track Heights" from package "Track Heights" (installed from user/pkg/version "di7dN0keyHdE1HAif7Qi47Oz53E2/cktudjn8j0000p510z6jbr3mz/ckvqyxwe0000231108n6d5mf6")
sf.soundflow.runCommand({
commandId: 'user:ckxxkr3od0001fe1020g092wz:cktudkfw20002p5109ic73tos',
props: {
trackSize: "small",
}
});
Basically, I make the track height 'medium' (I guess SF needs it to be like that in order to execute these functions...), and then if it's in waveform, it puts it in playlist, and vice versa. I then make the track heights 'small'.
However, as many of you know, if you hold your cursor right in between the tracks, there is an option to manually adjust the track height to a 'custom' height, in between small and medium. I personally need it to be '3 plugins' thick (for all playlists).
The steps I need to take in order to get to this seems to be a custom 'mouse drag' utility. I understand that's not preferred, as it's unstable, but what I think it could be from a relative UI position, maybe say, after you make the track height small, it's only "_"spaces away on the y position. The drag space could theoretically be ANYWHERE below the track, in between that and the next track, I just currently don't know how to write a script that basically says "look for a UI Element (read, wave, play etc.), click mouse, drag it down one 'tick', and done"
Anyone who could help? I'm very close to figuring out by piecing together other peoples' scripts, but someone more well versed could really help!!
Jordan
Linked from:
- Christian Scheuer @chrscheuer2022-01-09 21:31:58.899Z
Hi Jordan,
You should get the frame of the track by doing
sf.ui.proTools.selectedTrack.frame
- this will give you the y coordinate and the height (inframe.y
andframe.h
). Add those together, then you have the y coordinate of the track boundary.
Then use thesf.mouse.simulateDrag
action to simulate a mouse drag from that point to somewhere else. Experiment to find the exact amount of pixels to drag downwards.
You'll also need to give it an x coordinate of course. You can get that from the track'sx
coordinate and then just add some pixels so you get a little further in.Christian Scheuer @chrscheuer2022-01-09 21:32:53.505Z
This will be easiest if you start by setting the track to one of the predetermined heights so that it's always a set amount of pixels you need to drag to expand it.
Jordan Pascual @Jordan_Pascual
God I feel so dumb... I don't even know how to run/'do' the "sf.ui.proTools.selectedTrack.frame " command... gah
I do have the predetermined height of 'small', but I am a little lost on how to plug 'sf.ui.proTools.selectedTrack.frame' into the script to have it pull up frame.y and frame.h.... Sorry for the newb questions.
Raphael Sepulveda @raphaelsepulveda2022-01-09 22:19:21.975Z2022-01-09 22:57:55.992Z
Hey @Jordan_Pascual !
This is an interesting approach!
Give the code below a shot and let me know if it works on your end. It does everything you're looking to do, or at least it should lol Like you mentioned, mouse-clicking can be unstable.
For anyone else reading, I tried using
sf.mouse.simulateDrag()
but was getting unexpected results—the track height would change again as the mouse pointer returned to its original position. So I broke it down and added some dynamic waiting in order to get it to work correctly./** @param {{ direction?: "up" | "down", trackHeightGridUnits?: number }} [args] */ function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const f = track.frame; const popupMenu = track.popupMenuOpenFromElement({ relativePosition: { x: f.w - 10, y: 5 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'Create New...').isEnabled }); } function main() { const targetTrackHeight = 61 const selectedTrack = sf.ui.proTools.selectedTrack; if (!selectedTrack.displaySelectorButton.invalidate().exists) { setTrackHeight('small'); } if (['waveform', 'wave'].includes(selectedTrack.displaySelectorButton.value.invalidate().value)) { selectedTrack.trackDisplaySelect({ displayPath: ['playlists'] }); if (selectedTrack.frame.h !== targetTrackHeight) { setTrackHeight('small'); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } } else { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); } } main();
Jordan Pascual @Jordan_Pascual
Dude! Raphael! You rock! Thanks to Christian as well!
I'm one of those dudes that always wants to learn how to fish, instead of getting the fish served to him, but this is the best of both! I'm such a newb when it comes to scripting, so I'm going to try breaking down the code, and understanding each of these commands.
I've tested this on 10 tracks already, and so far so good! Only thing is that when it returns to WAVEFORM, it returns to the 'small' height... to me, it doesn't matter what height that's in, as I'll adjust it to preference, however, is it possible to have it return to the '3 plugins customized' height?
Learning a lot here!
Jordan
Jordan Pascual @Jordan_Pascual
Okay super special thanks to @chrscheuer and definitely @raphaelsepulveda , as Raphael made this awesome script.
Raphael, I modified it slightly. As I said, I suck at this and am a newb, so I tried fiddling around a bit, and changed a few parameters at the bottom... at the final 'if... else...' thing. If this is the right way to do it, lmk!
For anyone else reading, who doesn't understand stuff (like me).... You can customize the 'trackHeightGridUnits' at the bottom to be more than '1', if you, say, want 4 plugins thick.... the '1' grid unit is about exactly one 'plugin' thick, so that's the unit measured.
I then added a duplicate of the
changeTrackHeightWithMouse({
trackHeightGridUnits: 1,
direction: 'down'...so that when it returns to 'waveform', it will be the desired track height.
I might publish this in the store, with other 'customized' heights, so that everyone can choose! For example, you can have it toggle playlist at 3 plugins 'height', but then return it to waveform, and it can be 9 plugins 'height'!
You all rock, thanks so much! :)))
function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const f = track.frame; const popupMenu = track.popupMenuOpenFromElement({ relativePosition: { x: f.w - 10, y: 5 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'Create New...').isEnabled }); } function main() { const smallTrackHeight = 43; const selectedTrack = sf.ui.proTools.selectedTrack; if (selectedTrack.frame.h !== smallTrackHeight) { setTrackHeight('small'); } if (['waveform', 'wave'].includes(selectedTrack.displaySelectorButton.value.invalidate().value)) { selectedTrack.trackDisplaySelect({ displayPath: ['playlists'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } else { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }) } } main();
- OOwen Granich-Young @Owen_Granich_Young
Cool to see this pop up guys, seems like a really cool one to tweak to put on steam deck Knobs...
- In reply toJordan_Pascual⬆:
Raphael Sepulveda @raphaelsepulveda2022-01-09 23:06:34.475Z2022-01-09 23:13:18.830Z
Nice!!
Yeah, I know what you mean. This one had a couple of challenges in there that made it a little tricky, but we got there!
Reading through the code and trying to make sense of everything is definitely the best way to learn, so I encourage you to do so. If you have any specific questions, I'd be happy to answer them!
I updated the code I posted above so that the track size is left at your custom height when returning to waveform view.
Jordan Pascual @Jordan_Pascual
Awesome! What's also great for me, is that I just compared your revision to what I had attempted, and they seem identical! I'll start learning soon enough haha! I'll keep brainstorming more ideas for Soundflow and see ya soon! Thanks so much
J
- In reply toraphaelsepulveda⬆:
Jordan Pascual @Jordan_Pascual
@raphaelsepulveda Hey Raphael! It's been a second! So, with the current version of PT, this code no longer seems to work for some reason. As a refresher, this was a custom height adjustment script. It seems to stop at Line 48 on the code. I think it stops at the drag simulation but I'm not sure!
Thanks!
J
Raphael Sepulveda @raphaelsepulveda2023-08-28 20:04:19.673Z
Hey @Jordan_Pascual, just tested here on PT 2023.6 and it's still rocking—tested the script you marked as the solution on this thread.
Line 48 is:
callback: () => sf.ui.proTools.getMenuItem('File', 'Create New...').isEnabled
This is a way of verifying if PT is responsive by checking the status of the File > Create New... menu item. On 2023.6, that menu item has not changed, so maybe this is not the issue?
If you can provide more info, I'll be able to better assist.
Jordan Pascual @Jordan_Pascual
@raphaelsepulveda Ahhhhh I think this is the issue... I am currently running the Beta version of PT (2023.9) and it seems NOT to have that menu option! Is there a workaround?
Raphael Sepulveda @raphaelsepulveda2023-08-29 16:43:32.196Z2023-10-01 20:55:06.012Z
Ah, yes I can see that. Since this is a public forum it'd probably be best not to discuss PT Beta details here, but the fix is pretty simple. On line 48 replace
"Create New..."
, with the menu item that has replaced it.EDIT:
"Create New..."
is now"New..."
starting on PT 2023.9Jordan Pascual @Jordan_Pascual
Hey there! Since PT 2023.9 is now officially released, just for public information, the 'Create New' is now replaced with 'New', so the updated script that should work is...
function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const f = track.frame; const popupMenu = track.popupMenuOpenFromElement({ relativePosition: { x: f.w - 10, y: 5 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'Create New...').isEnabled }); } function main() { const smallTrackHeight = 43; const selectedTrack = sf.ui.proTools.selectedTrack; if (selectedTrack.frame.h !== smallTrackHeight) { setTrackHeight('small'); } if (['waveform', 'wave'].includes(selectedTrack.displaySelectorButton.value.invalidate().value)) { selectedTrack.trackDisplaySelect({ displayPath: ['playlists'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } else { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }) } } main();
- In reply toraphaelsepulveda⬆:
Jordan Pascual @Jordan_Pascual
Hey again! I'm seeming to have issues with the current release (2024.3). Can you try running the script and tell me what's going on your end of things? Thanks!
J
Raphael Sepulveda @raphaelsepulveda2024-03-25 17:46:49.164Z2024-03-26 01:29:21.600Z
Hey @Jordan_Pascual, tested this last version and made a few minor changes to make it work on PT 2024.3.
Let me know if it behaves for ya.function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'New...').isEnabled }); } function main() { const smallTrackHeight = 43; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const selectedTrack = sf.ui.proTools.selectedTrack; if (selectedTrack.frame.h !== smallTrackHeight) { setTrackHeight('small'); } if (['waveform', 'wave'].includes(selectedTrack.displaySelectorButton.value.invalidate().value)) { selectedTrack.trackDisplaySelect({ displayPath: ['playlists'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } else { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } } main();
Jordan Pascual @Jordan_Pascual
Edit: Nevermind! This works!!
Thanks so much @raphaelsepulveda !
Raphael Sepulveda @raphaelsepulveda2024-03-26 01:31:10.616Z
@Jordan_Pascual, it wasn't happening when I tested it but it sounds like the cache needs invalidating. I adjusted the previous script I posted. Give that a shot!
Jordan Pascual @Jordan_Pascual
Works perfect! Thanks!
One last question! Can you post a narrowed down script of JUST changing it to be 1 or 3 thick, without the waveform/playlist toggle? i.e. just changing the track height? Just to have as an alternate.
Edit: For other people trying to find this, should I ask this in a separate forum post for all the different sizes? It seems like the old methods all don't work now. Thanks so much!
Raphael Sepulveda @raphaelsepulveda2024-03-26 18:55:14.618Z
@Jordan_Pascual, sure thing. This one will toggle between the "small" track height and the 3-insert height:
function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'New...').isEnabled }); } function main() { const smallTrackHeight = 43; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const selectedTrack = sf.ui.proTools.selectedTrack; if (selectedTrack.frame.h !== smallTrackHeight) { setTrackHeight('small'); return; } changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } main();
Raphael Sepulveda @raphaelsepulveda2024-03-26 18:59:38.432Z
@Jordan_Pascual, as far as setting the track height to any other size, that has been addressed in other posts recently, but you can find the latest version in this very script. It's this function:
function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } setTrackHeight("small");
If you have existing scripts that are not exactly like this, you can get them back to work by making sure the
anchor
andrelativePosition
properties are set the way they are here.Jordan Pascual @Jordan_Pascual
@raphaelsepulveda Awesome!! Do you mind posting and telling me what the script for JUST making a plugin 3 spaces thick would be? I know that isn't quite the same as the function listed directly above, so just wanted to isolate that part of the script! I also am trying to understand what originally 'broke' the code functionality wise with the new update (just as a learning moment!) Thanks!
Raphael Sepulveda @raphaelsepulveda2024-03-28 03:32:22.461Z
@Jordan_Pascual, the script to make a track have a 3-insert height is this one minus line 62. When you remove that line, the script will always set it to that height instead of toggling between it and the small height.
Based on your question, I think you were expecting something shorter, but since the 3-insert height is not a standard track height, it requires a few moves to get there.
Raphael Sepulveda @raphaelsepulveda2024-03-28 03:36:43.981Z
@Jordan_Pascual Regarding what originally broke the script, it was a combination of Pro Tools and SoundFlow changes behind the scenes.
In response to a UI change in Pro Tools, SoundFlow now defaults to clicking buttons in the center instead of the top-left—this is called an anchor. Making this change prevents many issues with PT 2024.3+ but makes certain scripts that relied on the old default anchor value not work anymore. This was one of them, specifically this part:
function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const f = track.frame; const popupMenu = track.popupMenuOpenFromElement({ relativePosition: { x: f.w - 10, y: 5 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); }
In line 7, we're assuming that the anchor is the top-left of the selected track, so we're adding the full length of a track (
f.w
) and subtracting 10px on thex
axis (for safety) so that the click happens on the right edge of the track, thus bringing up the popup menu with the different track height options.With the new anchor value being the center, this logic makes the click happen somewhere in the timeline and not in the track itself. As a result, nothing happens, therefore the following fix:
function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); }
If you look at lines 6 and 7 of this updated function, we're making sure the
anchor
value is set toMidRight
instead of the default. This guarantees the click will happen at the right edge of the track. And just like we did before, on therelativePosition
, we're offsetting thex
axis by -10px to get a margin of safety. This ensures the click will happen in the right place.Hopefully that all makes sense. All in all, this kind of change rarely happens so I wouldn't worry about it happening again in the near future (famous last words lol)
Jordan Pascual @Jordan_Pascual
Wonderful! Thank you for all you knowledge! Much appreciated man :)
- In reply toraphaelsepulveda⬆:
Jordan Pascual @Jordan_Pascual
@raphaelsepulveda Hiiiiiii i'm back again, so it seems haha!
So I've been experiencing this weird issue, that every now and then, when I execute any of the size track commands (seemingly, step 1, making it 'mini' or 1 plugin thick) the 'color palette' will be brought up. Is this happening on your end at all?
I currently have these commands chained in a script (i.e. I will have it set up to make the 1st track one plugin thick, and then the next track 3 plugins thick) by utilizing the 'semicolon / ;' PT function, to go to the next track after a desired time. After the bug with the color palette, it will instead skip around and usually go to the NEXT track BELOW the other, and miss a few steps.
Is there a better way of going about this? Is the color palette being brought up because of the (x: -10 ) grid position hitting upon it? Just taking guesses!
Jordan
//Calling command "Group Toggle DeActivate (Suspend)" from package "Custom" sf.soundflow.runCommand({ commandId: 'package:cl0t292wr0000gl10j5dzaa5o', props: {} }); sf.ui.proTools.selectedTrack.trackSelect(); sf.wait({ intervalMs: 600, }); function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } setTrackHeight("mini"); sf.wait({ intervalMs: 600, }); sf.keyboard.press({ keys: "semicolon", }); function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'New...').isEnabled }); } function main() { const smallTrackHeight = 43; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const selectedTrack = sf.ui.proTools.selectedTrack; if (selectedTrack.frame.h !== smallTrackHeight) { setTrackHeight('small'); } if (['waveform', 'wave'].includes(selectedTrack.displaySelectorButton.value.invalidate().value)) { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } else { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } } main(); //Calling command "Group Toggle Active (Non-Suspend)" from package "Custom" sf.soundflow.runCommand({ commandId: 'package:cl0t184f70000ha10vk8xy6t0', props: {} });
Raphael Sepulveda @raphaelsepulveda2024-03-28 22:59:25.246Z
@Jordan_Pascual mmm, I'm not sure what could be causing the color palette to come up. That's a weird one.
I tested this script you posted, without the "Group Toggle DeActivate (Suspend)" and "Group Toggle Active (Non-Suspend)" commands since those live on your account only, and it all worked correctly.“Is the color palette being brought up because of the (x: -10 ) grid position hitting upon it?”
I don't think so since the color palette should only come up by double-clicking on the far left side of a track. In this case, we're single-clicking on the opposite edge of the track.
This one is tricky since I'm unable to recreate it. To assist you further I'm going to need the following:
- The script for your "Group Toggle DeActivate (Suspend)" command
- macOS version you're on
- PT version
- A video showing the issue so I can try and find some clues based on the way you have things laid out.
Jordan Pascual @Jordan_Pascual
Sure! I'll DM you some of the info for NDA reasons, but here's the public info...
Script for Group Toggle DeActivate (Suspend)
sf.ui.proTools.groupsEnsureGroupListIsVisible(); var groupListPopup = sf.ui.proTools.groupsOpenListPopupMenu().popupMenu; groupListPopup.menuClickPopupMenu({ menuPath: ["Suspend All Groups"], targetValue: 'Enable' }); sf.ui.proTools.appActivateMainWindow();
The Group Toggle Activate (Non-Suspend) command is relatively the same
sf.ui.proTools.groupsEnsureGroupListIsVisible(); var groupListPopup = sf.ui.proTools.groupsOpenListPopupMenu().popupMenu; groupListPopup.menuClickPopupMenu({ menuPath: ["Suspend All Groups"], targetValue: 'Disable' }); sf.ui.proTools.appActivateMainWindow();
MacOSX is Catalina (10.15.7 Build (19H2026)
Not sure how to send a vid here on SF, but I'll DM it!
Raphael Sepulveda @raphaelsepulveda2024-03-29 17:17:42.971Z
@Jordan_Pascual, thanks for sending all that stuff over!
As we talked about off the forum, the issue seems to happen when you run this script on tracks that are nested two folders deep, but now that I've done some testing I'm pretty sure I've found the culprit—you have to make sure that the track list pane is not too narrow.
In my test, I made the track list as narrow as possible and, when I ran the script, the color palette popped up just as you described. I then made the track list a tiny bit wider and the script started to work normally! So yeah, just make sure to adjust to track list width and you should be good!
Jordan Pascual @Jordan_Pascual
@raphaelsepulveda Thanks again for all your help on this! The track list workaround works nicely! I don't typically have too many 'two folders deep scenario' so this should be fine!
Sorry this thread has gotten so long already but I ONE MORE quick question again with this script...
Oftentimes, I find the script doesn't function towards the end of the script (specifically on the 'trackHeightGridunits / down' part, making the adjust from 2 to 3 'units). Usually this happens when the session has a lot of tracks/data, and is a bit 'bogged down' memory wise.
I think this is due to the 'wait' command not being used properly, and the system needs time to recoup. How would YOU write this script? Would you use the 'wait for PT to become responsive' script to replace the wait?
As a reminder the goal is to...
- Suspend Group (De-active if Active)
- Choose selected track
- Make it 1 Unit thick (mini)
- Choose the track below it (I use semicolon)
- Make that 3 Units thick (as per your script)
- Un-Susupend Group (Make Active again)
Thanks my dude
Raphael Sepulveda @raphaelsepulveda2024-04-01 20:53:51.340Z
@Jordan_Pascual, lol no worries.
There's a couple things I'd modify, but to make sure we take care of the exact problem you're having, can you send me another video next time you see it happen? Just like last time, some things are easier to spot when you see them happen.
FYI, you can upload the video to Dropbox and post the link here.
Jordan Pascual @Jordan_Pascual
Here ya go! Hopefully this works, my Dropbox is so full haha
Raphael Sepulveda @raphaelsepulveda2024-04-02 18:59:51.747Z
@Jordan_Pascual, perfect, thank you!
I think I see the problem. Seems like at 0:04, whenever it changes the second track to size small, it takes a little longer than usual on this bogged-down session, but the script is counting on it being instant so it tries to make it 3-insert height before it's supposed to.
Ok, let's try an easy approach, and if doesn't work I'll write a more intricate solution. Try adding
waitForPtToBeResponsive()
at the end of thesetTrackHeight
function, so that it looks like this:function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); waitForPtToBeResponsive(); }
Jordan Pascual @Jordan_Pascual
@raphaelsepulveda I tried inserting that script where the other was before, but it actually outputs an error that the 'function is undefined'.
More importantly, there actually WAS a predefined script for the 'waitForPtToBeResponsive', utilizing the 'File', 'New...' callback function. (predefined around Line 83 on the above script), and right after the 'popupMenu.menuClickPopupMenu' part of the script, there already was this line...
function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'New...').isEnabled }); }``` Edit: I've tried putting the above section in the FIRST part of the script, as well as the regular line 'waitForPtToBeResponsive', in various spots, but every time, it still does the same thing.
Raphael Sepulveda @raphaelsepulveda2024-04-03 04:56:16.393Z
For anyone else following along, @Jordan_Pascual and I figured this out offline and the fix was to put a
sf.wait({ intervalMs: 250 });
between lines 59 and 60 of this script 👌🏼Jordan Pascual @Jordan_Pascual
Yes! Huge thanks to @raphaelsepulveda for really breaking down this script with me, and helping me condense it down. Such a huge help!
To anyone who might be lost in the thread, the post HERE is the updated, more 'drawn out' version of the script, with the new 'Wait' line inserted. I have it a bit more condensed down on my end, but this script is to JUST make the track '3 Plugins Thick'. I may publish just this part of the script with changeable variables (up, down, 'Grid Units'). (Note: This doesn't include the 'Playlist' Toggling, that can be found above!)
Cheers!
sf.ui.proTools.selectedTrack.trackSelect(); sf.wait({ intervalMs: 600, }); function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } setTrackHeight("mini"); sf.wait({ intervalMs: 600, }); sf.keyboard.press({ keys: "semicolon", }); function changeTrackHeightWithMouse({ direction = 'down', trackHeightGridUnits = 1, }) { const trackHeightGridPixelsPerUnit = 15; const xOffset = 50; trackHeightGridUnits = Math.abs(trackHeightGridUnits); if (direction === "up") trackHeightGridUnits = -trackHeightGridUnits; const frame = sf.ui.proTools.selectedTrack.frame; const frameBottomLeft = frame.y + frame.h; const frameBottomTargetPositionY = frameBottomLeft + (trackHeightGridUnits * trackHeightGridPixelsPerUnit); const x = frame.x + xOffset; const endPosition = { x, y: frameBottomTargetPositionY }; function doWithMouseAndRestorePosition({ action }) { const mousePosition = sf.mouse.getPosition().position; action(); sf.mouse.setPosition({ position: mousePosition }); } doWithMouseAndRestorePosition({ action: () => { sf.mouse.down({ position: { x, y: frameBottomLeft } }); sf.wait({ intervalMs: 250 }); // Increase time if it starts failing again sf.mouse.drag({ position: endPosition, }); waitForPtToBeResponsive(); sf.mouse.up({ position: endPosition }); waitForPtToBeResponsive(); } }); } function setTrackHeight(size) { const track = sf.ui.proTools.selectedTrack; track.trackScrollToView(); const popupMenu = track.popupMenuOpenFromElement({ anchor: "MidRight", relativePosition: { x: - 10, y: 0 }, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function waitForPtToBeResponsive() { sf.waitFor({ callback: () => sf.ui.proTools.getMenuItem('File', 'New...').isEnabled }); } function main() { const smallTrackHeight = 43; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const selectedTrack = sf.ui.proTools.selectedTrack; if (selectedTrack.frame.h !== smallTrackHeight) { setTrackHeight('small'); } if (['waveform', 'wave'].includes(selectedTrack.displaySelectorButton.value.invalidate().value)) { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } else { selectedTrack.trackDisplaySelect({ displayPath: ['waveform'] }); waitForPtToBeResponsive(); changeTrackHeightWithMouse({ trackHeightGridUnits: 1, direction: 'down' }); } } main();