Hello,
Is there any way to check if defined group is active or not?
Thank you!
Linked from:
- In reply toSamuel_Skubla⬆:Christian Scheuer @chrscheuer2020-10-15 10:52:33.293Z
This should work :)
function isGroupActive(groupName) { let grp = sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => { let btn = r.childrenByRole('AXCell').allItems[1].buttons.first; return { groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn, isActive: btn.title.invalidate().value.indexOf('Active ') === 0, row: r, }; }).filter(g => g.groupName === groupName)[0]; if (!grp) throw `Group with name "${groupName}" was not found`; return grp.isActive; } if (isGroupActive("Group 2")) { log('Yes'); } else { log('No'); }
Christian Scheuer @chrscheuer2020-10-15 10:55:41.245Z
Note, this could also be augmented to a "setGroupActive" function where you specify exactly the desired state instead of toggling:
/** * @param {string} groupName * @param {boolean} targetValue Set to true (active) or false (inactive) */ function setGroupActive(groupName, targetValue) { let grp = sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => { let btn = r.childrenByRole('AXCell').allItems[1].buttons.first; return { groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn, isActive: btn.title.invalidate().value.indexOf('Active ') === 0, row: r, }; }).filter(g => g.groupName === groupName)[0]; if (!grp) throw `Group with name "${groupName}" was not found`; if (grp.isActive !== !!targetValue) grp.btn.elementClick(); } setGroupActive("Group 2", true);
- In reply toSamuel_Skubla⬆:Erik Griekspoor @Erik_Griekspoor
So what does this do? Would be fantastic if you could see on the toggle button on your streamdeck if a group is actived or not.
Erik Griekspoor @Erik_Griekspoor
Ah I see now how it works, this is already great, The only disadvantage is that you need two buttons now instead of one. Is it possible to highlight a button on the streamdeck when it is activated?
Samuel Škubla @Samuel_Skubla
This should work.
/* * @param {string} groupName */ function setGroupActive(groupName) { let grp = sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => { let btn = r.childrenByRole('AXCell').allItems[1].buttons.first; return { groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn, isActive: btn.title.invalidate().value.indexOf('Active ') === 0, row: r, }; }).filter(g => g.groupName === groupName)[0]; if (!grp) throw `Group with name "${groupName}" was not found`; grp.btn.elementClick(); } setGroupActive("Group 2");
Erik Griekspoor @Erik_Griekspoor
Thanks! It does toggle the Group but I dont see something changing on my streamdeck button though, should I have a certain color icon or something?
Samuel Škubla @Samuel_Skubla
I think this is currently not possible by easy way, but I know there is a way to change icons from script. Maybe someone could give us a hand with this one.
Erik Griekspoor @Erik_Griekspoor
That would be awesome..
- In reply toSamuel_Skubla⬆:Erik Griekspoor @Erik_Griekspoor
These scripts somehow dont work anymore, could somebody look in to this?
Also I'm still very interested in the Icon on the streamdeck changing when a group is activated or not.. - In reply toSamuel_Skubla⬆:Erik Griekspoor @Erik_Griekspoor
I get the notification:
Group with name "V_FX_A" was not found
(Toggle Group V_FX_A line 11)The name of the group is exactly the some though..
- In reply toSamuel_Skubla⬆:Erik Griekspoor @Erik_Griekspoor
Aha, I found out its because a VCA is assigned to the group.
How can I make this script work with VCA's asigned to the group?function toggleGroupActive(groupName) {
sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => ({
groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1],
btn: r.childrenByRole('AXCell').allItems[1].buttons.first,
row: r,
})).filter(g => g.groupName === groupName)[0].btn.elementClick();
}toggleGroupActive("Group 2");
- In reply toSamuel_Skubla⬆:Erik Griekspoor @Erik_Griekspoor
Ah, I found out that if you add the (VCANAME) to the groupname it works!