hello,
I'm trying to call the delete tracks dialog(if there's clips on the track) and when I press again would press delete button.
But I can't find the correct ui for the window.
This calls the menu(if there's clips on the track)
sf.ui.proTools.trackDelete();
}
What would be the script to press "Delete"?

Thank you
- Dustin Harris @Dustin_Harris
Try this:
sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick();
samuel henriques @samuel_henriques
Thank you Dustin,
I've been trying this one, but I get error all the time10.09.2020 08:14:42.23 [Backend]: Javascript error with innerexception: SoundFlow.Shortcuts.AXUIElementException: kAXErrorInvalidUIElement
at SoundFlow.Shortcuts.AXUIElement.GetSubElements(String) + 0x1a4
at SoundFlow.Shortcuts.Ax.AxNodes.AxElementArrayFromRole.get_RawItems() + 0x56
at SoundFlow.Shortcuts.Ax.AxNodes.AxElementArray.get_Length() + 0x28
at SoundFlow.Shortcuts.Ax.AxNodes.AxElementArrayObjectWrapper..ctor(Engine, AxElementArray) + 0x69
at SoundFlow.Shortcuts.Automation.SoundFlowObjectConverter.TryConvert(Engine, O
10.09.2020 08:14:43.00 [StartMenu]: Uncaught TypeError: sender.emit is not iterable (cannot read property Symbol(Symbol.iterator)) Line 2188 electron/js2c/renderer_init.js
10.09.2020 08:14:43.03 [StartMenu]: Uncaught TypeError: sender.emit is not iterable (cannot read property Symbol(Symbol.iterator)) Line 2188 electron/js2c/renderer_init.js
10.09.2020 08:14:43.03 [Backend]: bject, JsValue&) + 0x83
Error: kAXErrorInvalidUIElement
(Delete Tracks_Sam scipt Copy line 6)<< Command: Delete Tracks_Sam scipt Copy [_____]
10.09.2020 08:14:43.24 [StartMenu]: Uncaught TypeError: sender.emit is not iterable (cannot read property Symbol(Symbol.iterator)) Line 2188 electron/js2c/renderer_init.js
I was trying to implement it as this script, and thought the element or code was wrong,
if (sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').exists) { sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick({ }) } else { sf.ui.proTools.trackDelete(); }
but
sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick();
Doesn't work by itself, so I guess the element and code are wrong
Thank you
Dustin Harris @Dustin_Harris
Maybe try it like this? (this works for me)
sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.trackDelete(); if (sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').exists) { sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick(); }
Does that help?
EDIT: It's not working reliably for me either, I'll try and figure out why.
samuel henriques @samuel_henriques
It worked once and then error.
But i'm would like to press once for the dialog and a second time to "delete".
Similar behaviour to this script I use to bring up the modify groups dialog and when im done, I press the same button on a surface and it clicks "ok"
if (sf.ui.proTools.windows.whoseTitle.is('Modify Groups').exists) { sf.ui.proTools.windows.whoseTitle.is('Modify Groups').first.buttons.whoseTitle.is('OK').first.elementClick() } else { sf.keyboard.press({ keys: "ctrl+cmd+g", }); }
Dustin Harris @Dustin_Harris
I'm still trying to figure out what's going on there, as it's weird on my system too. Are you on 2020.9 by any chance?
samuel henriques @samuel_henriques
I'm on PT Ultimate 2020.5.0
OSX 10.13.6Dustin Harris @Dustin_Harris
I was being silly and didn't catch needing to invalidate the confirmation dialog box.
@chrscheuer has the perfect answer here:
sf.ui.proTools.appActivateMainWindow(); if (sf.ui.proTools.getMenuItem('Track', 'Delete...').exists) { sf.ui.proTools.getMenuItem('Track', 'Delete...').elementClick(); sf.ui.proTools.confirmationDialog.invalidate().elementWaitFor(); sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick(); } else if (sf.ui.proTools.getMenuItem('Track', 'Delete').exists) { sf.ui.proTools.getMenuItem('Track', 'Delete').elementClick(); }
Christian Scheuer @chrscheuer2020-09-11 12:41:43.683Z
Thanks for sharing, Dustin!
Dustin Harris @Dustin_Harris
Thanks for solving our problem! :)
samuel henriques @samuel_henriques
hello,
thank you guys,
that works to go thru the dialog.
I'm still trying to make it show the dialog and them press again to delete.I've been fiddling with the code and got somewhere, not great yet tough.
sf.ui.proTools.appActivateMainWindow(); if (sf.ui.proTools.confirmationDialog.exists) { sf.ui.proTools.confirmationDialog.invalidate().elementWaitFor(); sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick(); } else sf.ui.proTools.trackDelete(); { }
press once, a SF error for line 3 will show
press again delete dialog will show
press again delete is pushedif track doesn't have any clips, it has the same behaviour.
sometimes during testing it works as intended with or without clips
thank you so much
Dustin Harris @Dustin_Harris
What do you need the whole script to do? The script I posted via Christian will delete a track without confirmation... if you need more than that let us know.
samuel henriques @samuel_henriques
I'd would like a button on a surface to delete tracks.
On first push of the button tracks without clips get deleted, if there are clips on tracks, the delete tracks dialog will show.
When the dialog is visible I press same button and tracks get deleted.
The script you made is great, but I would like the safety of the warning for the times when I'm sleeping on the wheel
Thank you so much for your patience.Dustin Harris @Dustin_Harris
Oh! now I get it!
Try this:sf.ui.proTools.appActivateMainWindow(); if (sf.ui.proTools.confirmationDialog.invalidate().buttons.whoseTitle.is('Delete').first.exists) { sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick(); } else if (sf.ui.proTools.getMenuItem('Track', 'Delete').exists) { sf.ui.proTools.getMenuItem('Track', 'Delete').elementClick(); } else if (sf.ui.proTools.getMenuItem('Track', 'Delete...').exists) { sf.ui.proTools.getMenuItem('Track', 'Delete...').elementClick(); sf.ui.proTools.confirmationDialog.invalidate().elementWaitFor(); }
samuel henriques @samuel_henriques
Yep its working.
Thank you so much
- In reply tosamuel_henriques⬆:Chris Shaw @Chris_Shaw2020-09-10 15:47:29.795Z
Weird. I use
sf.ui.proTools.trackDelete();
all the time and I never get the confirmation dialog - even when there are clips on the track.