No internet connection
  1. Home
  2. How to

How do I script a selection of a specific tool variant?

By John Rammelt @John_Rammelt
    2019-09-27 21:03:26.171Z

    I'm trying to make a script that selects the Grabber Object Tool and this just selects the standard Grabber:

    sf.ui.proTools.toolsSelect({
      tool: "Grabber",
    });
    

    I also tried finding out via the 'Add Action' in the Macro Editor if I could find any clues, which got me this:

    sf.ui.proTools.mainWindow.groups.whoseTitle.is('Cursor Tool Cluster').first.buttons.whoseTitle.is('Grabber tool (Object)').first.elementClick();
    

    However, this fails at "ClickButtonAction requires UIElement (ClickButtonAction)".
    I thought I was clever and put (Object) in the first script but it seems only the main Tool names 'Smart', 'Grabber', 'Trim' and 'Selector' are possible to use that way.

    Ideas?

    Solved in post #2, click to view
    • 9 replies
    1. Hi @John_Rammelt

      This one works for me:

      sf.ui.proTools.mainWindow.groups.whoseTitle.is('Cursor Tool Cluster').first.buttons.whoseTitle.startsWith('Grabber tool').first.popupMenuSelect({
          isRightClick: true,
          menuPath: ['Object']
      });
      
      Reply1 LikeSolution
      1. Explanation:

        It uses the same code to get to the grabber tool, but since that tool changes title based on what is selected, I changed it so that it's searching for a button whose title "starts with" "Grabber tool". Then I specify to right click on that element and choose "Object" from the popup menu.

        1. In reply tochrscheuer:
          JJohn Rammelt @John_Rammelt
            2019-09-27 21:14:19.356Z

            Hi Christian!
            Well, it kind of works but in an unexpected way; if I first mouse-click to select the Object Grabber, it also deselects the Smart Tool, which what I was after. I have another script to select the Smart Tool. With this script you gave me now, it selects the Grabber Object Tools BUT still as a Smart Tool. Do I make sense?

            1. JJohn Rammelt @John_Rammelt
                2019-09-27 21:23:19.779Z

                It is however working, so I think I'll just adapt to this for now. If I need to, I'll simply make a similar script for 'Time' (and 'Separation').

                1. In reply toJohn_Rammelt:

                  Hi John :)
                  You can force it to be non-smart-tool by first left-clicking the grabber tool like this:

                  
                  sf.ui.proTools.mainWindow.groups.whoseTitle.is('Cursor Tool Cluster').first.buttons.whoseTitle.startsWith('Grabber tool').first.elementClick();
                  sf.ui.proTools.mainWindow.groups.whoseTitle.is('Cursor Tool Cluster').first.buttons.whoseTitle.startsWith('Grabber tool').first.popupMenuSelect({
                      isRightClick: true,
                      menuPath: ['Object']
                  });
                  
                  1. JJohn Rammelt @John_Rammelt
                      2019-09-27 21:25:48.371Z

                      Excellent!

                2. In reply toJohn_Rammelt:
                  Dustin Harris @Dustin_Harris
                    2019-10-29 17:51:00.420Z2019-10-29 19:27:52.213Z

                    Hi to build on this, how does one capture the state of a button?
                    I want to make the selector tool toggle between 'Standard' and 'TCE' (and bypass the selection of 'Scrub' and 'Loop'...
                    So if I can check the state of the button:

                    EDIT 2 Found the answer in another post. I don't need to check the state, just check for not a current state :)

                    
                    sf.ui.proTools.appActivateMainWindow();
                    
                    if (sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.title.invalidate().value.indexOf('Time Compression') < 0) {
                        sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['TCE'], isRightClick: true });
                    } else {
                    
                    sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['Standard'], isRightClick: true });
                    
                    }
                    

                    Thanks!
                    EDIT: changed selector tool to trim tool.

                    1. JJoakim Bjerknes @Joakim_Bjerknes
                        2022-03-11 15:40:08.760Z

                        Hey Dustin, i need a way to togge between Time and Oject for grabber tool, but i cant seem to figure out how to change it from Trim tool

                        1. Dustin Harris @Dustin_Harris
                            2022-03-13 15:01:32.133Z

                            Hi @Joakim_Bjerknes , sorry for the late reply!
                            Try this and let me know if it works for you :)

                            sf.ui.proTools.appActivateMainWindow();
                            
                            let grabberTool = sf.ui.proTools.mainWindow.cursorToolCluster.grabberTool;
                            
                            if (grabberTool.title.invalidate().value !== "Grabber tool (Time)") {
                            
                                grabberTool.popupMenuSelect({
                                    menuPath: ['Time'],
                                    isRightClick: true,
                                });
                            
                            } else {
                            
                                  grabberTool.popupMenuSelect({
                                    menuPath: ['Object'],
                                    isRightClick: true,
                                });
                            
                            }