No internet connection
  1. Home
  2. How to

using SF to automatically switch to "Link to Source Media" in import session data / scripting import session data window

By Sean @SeanH
    2018-08-03 19:27:05.579Z

    So is it currently possible in SF to switch the pull-down menu In "Import Session Data" to "link to source media," regardless of what option is currently selected on that pulldown? Seems like it should be possible using similar scripts that are used to select settings in pro tools prefs. I only was able to figure out how to hit checkboxes in prefs though, not select options In pulldown menus.

    Solved in post #2, click to view
    • 22 replies

    There are 22 replies. Estimated reading time: 14 minutes

    1. This would do it:

      
      var dlg = sf.ui.proTools.dialogWaitForManual({ dialogTitle: 'Import Session Data' }).dialog;
      
      var popupBtn = dlg.groups.getByTitle('Media Options').popupButtons.allItems[1];
      popupBtn.popupMenuSelect({
          menuPath: ['Copy from source media']
      });
      
      ReplySolution
      1. Oops, but obviously change to "Link to source media (where possible)"

        1. SSean @SeanH
            2018-08-03 19:42:09.412Z

            thank you! Now i can use this as a jumping off point to do other pull down menus as well. I'm assuming something similar would work for "degree of thinning" in pro tools prefs as long as I swap out the proper titles and variables?

            1. Correct. You might need another layer of indirection (I think there might be two nested layers of groups in the prefs, but I don't remember fully)

              Feel free to post another thread about that if you need help.

              1. Maybe you should look into a UI element inspector. That will reveal title names, group names etc.
                I'm using the one that comes with Xcode. But Xcode is a big thing to install. @Oli_Em are you using something that's easier to install? I don't remember the name, but I think you mentioned it elsewhere.

                1. ?@anon6770933309
                    2018-08-04 08:03:57.996Z

                    I use UI Browser, costs $55, https://pfiddlesoft.com/uibrowser/
                    Or Accessibility Inspector, part of Xcode. An older stand alone version of Accessibility Inspector (version 4.0) is still available at Apple's Developer site, its part of the Accessibility Tools for Xcode, https://download.developer.apple.com/Developer_Tools/accessibility_tools_for_xcode__february_2012/accessibility_tools_for_xcode.dmg

          • S
            In reply toSeanH⬆:
            Sean @SeanH
              2018-08-03 19:52:49.620Z

              (I should probably file this in a separate idea thread, but this got me thinking) - but wouldn't it be cool if SF could have scripts, where the trigger isn't a button or hot-key etc, but rather a different default pro tools action itself triggering sound flow to do something additional.

              so for example, I would like SF to be able to automatically detect when I open the Import session data window using the default pro tools command, and every time this window is opened, it would just automatically also switch the pulldown to Link to Source media. Maybe there could be a hotkey trigger that would tell SF whether or not this passive script action is currently enabled.

              while this is a simple one that could just be accomplished by having a separate script that both opens import session data and selects options in it,

              I think the idea of "passive" commands in SF could be useful in other regards, that have other types of triggers. Things that are triggered either by TimeOfDay, or specific pro tools GUI elements being opened automatically triggering a script, etc. I don't know if passive is the right term for this, but it would be scripts that just happen in the background because SF detects something, rather then the user directly triggering SF to run the script.

              (sorry - I wrote this before your FB note about sitting on new advanced feature requests)

              :)

              1. That's a great idea, one that we have been thinking of in various ways ourselves. Please copy this whole text to an idea, so we can keep track of it :)
                No worries, I expect it to take a little time to get everybody on board with thinking more like a first time user - and it's still very valuable to keep track of these things. Even if we postpone implementing them, it's good to remember them.

              2. S
                In reply toSeanH⬆:
                Sean @SeanH
                  2018-08-03 20:22:01.275Z

                  OK so this is what I'm currently doing, its working pretty well:

                  sf.ui.proTools.menuClick({ menuPath: ['File', 'Import', 'Session Data...'] });
                  
                  sf.wait({ intervalMs: 5000 });
                  
                  var dlg = sf.ui.proTools.dialogWaitForManual({ dialogTitle: 'Import Session Data' }).dialog;
                  
                  var popupBtn = dlg.groups.getByTitle('Media Options').popupButtons.allItems[1];
                  popupBtn.popupMenuSelect({
                      menuPath: ['Link to source media (where possible)']
                  });
                  

                  could I change this so rather then a specific wait interval, SF just knows to wait for an undetermined amount of time while I navigate the Import window to the right session file, then doesn't trigger the rest of the command until the Import Session Data window actually opens?

                  currently if I don't put the extra wait interval, the command will error unless I select my session extremely quickly. it seems like the default amount of time SF will wait when you are using dialogWaitForManual is 2000 ms.

                  1. I think there's an option in dialogWaitForManual for you to set the timeout to 0, then it will wait indefinitely.

                    1. ?@anon6770933309
                        2018-08-04 10:54:16.224Z

                        think there's an option in dialogWaitForManual for you to set the timeout to 0

                        Wasn't it timeout: -1 to wait indefinitely? At least thats what works for me. 😉

                        1. @Oli_Em yes you're right! ;)
                          Timeout of 0 would just instantaneously time out, after checking one time.

                          1. SSean @SeanH
                              2018-08-05 00:05:36.152Z

                              so tried to figure it out on my own, but how do I format this -1 option into dialogWaitForManual?

                              ty!

                              1. @SeanH
                                All actions in SoundFlow take their parameters in an object (designated by enclosing curly brackets { } and separated by commas)

                                For instance, look how we select tracks. We call the action and give it an object {...} with each parameter specified by the parameter name, a colon, then its value and then a comma before the next parameter.

                                sf.ui.proTools.trackSelectByName({
                                    names: ['First Track'], 
                                    deselectOthers: true,
                                });
                                

                                In your sf.ui.proTools.dialogWaitForManual you are already specifying one parameter, the dialogTitle:

                                 sf.ui.proTools.dialogWaitForManual({ dialogTitle: 'Import Session Data' })
                                

                                So to add one more parameter you just need to add a comma after the 'Import Session Data', (and I'm now adding a new line as well to make it look better):

                                 sf.ui.proTools.dialogWaitForManual({
                                    dialogTitle: 'Import Session Data',
                                    timeout: -1
                                });
                                
                                1. Bear in mind this is not the complete solution, just an explanation of how you add a parameter. It might also be the wrong name for the parameter, can't check atm.

                                  1. SSean @SeanH
                                      2018-08-05 01:21:07.589Z

                                      thanks so much for the detailed explanation!

                                      the timeout: -1 is what i was looking for.

                                      this is what it ended up needing, working perfect now

                                      var dlg =  sf.ui.proTools.dialogWaitForManual({
                                          dialogTitle: 'Import Session Data',
                                          timeout: -1
                                      }).dialog;
                                      
                                      1. Great!
                                        If you didn't know already, whenever you are inside the curly brackets { }, for instance right after the first { or right after a comma , ending a previous parameter, you can hit F2 and it will give you suggestions, eg. it will tell you what parameters are available.

                        2. In reply toSeanH⬆:
                          Stefan Möhl @Stefan_Mohl
                            2019-09-19 15:45:52.409Z

                            Hello,

                            I am trying to get the settings for the Timecode Mapping Options:
                            And I ended up with this which is a wor around because I assume that "Maintain absolute timecode values" are selected by default.

                            sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.popupButtons.whoseTitle.is('Maintain absolute timecode values').first.popupMenuOpenFromElement(); sf.keyboard.press({ keys: "down, down, return", });

                            How can I change this that always Map start timecode is selectd.

                            And I tried to get a default timecode value to 10:00:00:00.
                            I tried the following:
                            sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementSetTextAreaValue({ value: "10:00:00:00", });

                            but nothing happens. I think I miss something.
                            Can someone give me a hint on that.
                            Best Stefan

                            1. Hi @Stefan_Mohl.

                              Did you convert this from a Macro action? - pretty cool.
                              You need to use the popupMenuSelect action instead of popupMenuOpenFromElement. Or, in a macro, use "Open & Select Popup Menu Item from Element".
                              This action will allow you to specify the exact item to select instead of simulating keystrokes.

                              For the 2nd question, try using the "Set Text Field With Text Area Value" action instead.

                            2. In reply toSeanH⬆:
                              Stefan Möhl @Stefan_Mohl
                                2019-09-20 08:17:53.737Z

                                Yes I copy the code from the macro to the script.

                                I tried different options but I can´t get it to work.
                                I copied the lines that were used for Media Options like this

                                var popupBtn2 = dlg.groups.getByTitle('Timecode Mapping Options:').popupButtons.allItems[1];
                                popupBtn2.popupMenuSelect({
                                    menuPath: ['Map start timecode to']
                                });
                                

                                This throws an exception of TypeError

                                And

                                sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.popupButtons.whoseTitle.is('Map start timecode to').first.popupMenuSelect();
                                

                                works only if "Map start timecode to" is already show which is obvious because I am searching for the title.
                                I can´t figure out who to click on that popup menu and select my desired item.

                                And for the timecode value I tried the action from your suggestion but it doesn´t change the time.

                                sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementClick();
                                
                                sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementSetTextFieldWithAreaValue({
                                    value: "10:00:00:00",
                                });
                                
                                1. You were very close :)

                                  This code works for me:

                                  
                                  sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.popupButtons.first.popupMenuSelect({
                                      menuPath: ['Map start timecode to']
                                  });
                                  
                                  sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementClick();
                                  sf.keyboard.type({ text: '10:00:00:00' });
                                  sf.keyboard.press({ keys: 'enter' });
                                  
                                2. In reply toSeanH⬆:
                                  Stefan Möhl @Stefan_Mohl
                                    2019-09-23 19:37:11.656Z

                                    So close .-)
                                    Thank you Christian. It is working and it will be a huge timesaver.