No internet connection
  1. Home
  2. How to

Select clip from clip list by name?

By Ivan Che @Ivan_Che
    2021-02-12 09:23:42.591Z

    Hi guys :)
    So this feels like something that could be done...

    let allClips = sf.ui.proTools.mainWindow.clipListView.childrenByRole("AXRow").allItems;
    let fullClips = allClips.filter(clip => !clip.children.allItems[1].children.first.value.value.includes('-'));
    
    fullClips.forEach(clip => {
        let value = clip.children.allItems[1].children.first.value.value.split('"')[1];
        if (selectedClipFullClipNames.includes(value)) { //array of needed clip names
            log(value); //this returns the clip names I want to click on, is there a way to do that from here??
            clip.elementClick(); //this doesn't work
        };
    });
    
    
    //maybe even something simple like like this? :)
    selectedClipFullClipNames.forEach(clipName => {
        selectClipFromClipListByName({ names: [clipName] });
    });
    

    Thanks!

    • 2 replies
    1. Hi Ivan,

      I'm not at a PT computer right now, but AFAIK you'll need to choose a specific button child in the row to be able to click it.
      The hierarchy is Row -> Cell -> Button. The buttons are the ones that can be clicked AFAIK.

      1. In reply toIvan_Che:

        Try this Ivan.
        It filters the search list first, and that made it easier for me to select the clip, as I had to use mouseCLickElement in order for the clip to get selected in the main window.

        function selectAudioFileInClipList(clipName) {
            const clipsList = sf.ui.proTools.mainWindow.clipListView;
            const rows = clipsList.children.whoseRole.is("AXRow").invalidate();
        
            let clipList = sf.ui.proTools.mainWindow.clipListView.children.whoseRole.is("AXRow")
        
            let selectedClipRows = rows.filter(row => {
                return row.childrenByRole("AXCell").allItems[1].childrenByRole("AXStaticText").first.value.value.match(clipName)
            });
            selectedClipRows[0].childrenByRole("AXCell").allItems[1].childrenByRole("AXStaticText").first.mouseClickElement()
        }
        
        function filterForAudioClipNameInListSelectThenDeselect(clipName) {
            sf.keyboard.press({ keys: 'cmd+shift+f' })
        
            sf.ui.proTools.windows.whoseTitle.is("Find Clips").first.checkBoxes.whoseTitle.is("By name").first.checkboxSet({ targetValue: "Enable" })
            sf.ui.proTools.windows.whoseTitle.is("Find Clips").first.textFields.first.elementSetTextFieldWithAreaValue({ value: clipName })
            sf.ui.proTools.windows.whoseTitle.is("Find Clips").first.buttons.whoseTitle.is("OK").first.elementClick()
        
            selectAudioFileInClipList(clipName)
            
            sf.keyboard.press({ keys: 'cmd+shift+d' })
        }