No internet connection
  1. Home
  2. How to

Delete tracks dialog window

By samuel henriques @samuel_henriques
    2020-09-09 18:35:57.272Z

    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

    Solved in post #9, click to view
    • 15 replies
    1. Dustin Harris @Dustin_Harris
        2020-09-10 03:32:22.430Z

        Try this:

        sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick();
        
        1. samuel henriques @samuel_henriques
            2020-09-10 07:25:36.180Z

            Thank you Dustin,
            I've been trying this one, but I get error all the time

            10.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

            1. Dustin Harris @Dustin_Harris
                2020-09-10 21:46:17.210Z

                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.

                1. samuel henriques @samuel_henriques
                    2020-09-10 22:25:44.630Z

                    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",
                    });
                    }
                    
                    1. Dustin Harris @Dustin_Harris
                        2020-09-11 00:26:21.356Z

                        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?

                        1. samuel henriques @samuel_henriques
                            2020-09-11 07:23:16.270Z

                            I'm on PT Ultimate 2020.5.0
                            OSX 10.13.6

                            1. Dustin Harris @Dustin_Harris
                                2020-09-11 12:25:57.964Z

                                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();
                                }
                                
                                ReplySolution
                                1. Thanks for sharing, Dustin!

                                  1. Dustin Harris @Dustin_Harris
                                      2020-09-11 12:43:09.035Z

                                      Thanks for solving our problem! :)

                                      1. samuel henriques @samuel_henriques
                                          2020-09-11 22:30:20.584Z

                                          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 pushed

                                          if 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

                                          1. Dustin Harris @Dustin_Harris
                                              2020-09-11 22:37:00.541Z

                                              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.

                                              1. samuel henriques @samuel_henriques
                                                  2020-09-11 23:30:45.282Z

                                                  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.

                                                  1. Dustin Harris @Dustin_Harris
                                                      2020-09-11 23:41:19.247Z

                                                      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();
                                                      }
                                                      
                                                      1. samuel henriques @samuel_henriques
                                                          2020-09-11 23:46:18.787Z

                                                          Yep its working.
                                                          Thank you so much

                                2. 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.