Pro Tools Main Counter and Gridlines toggle
I am a new SoundFlow user and came across a Youtube video of Kitch Membery illustrating a script that he created for a Pro Tools keyboard shortcut to toggle through several states (from Timecode to Bars and Beats) of the Main Counter. I have never scripted before and am wanting to do something similar but involving both the Main Counter and the Timeline Grid as well. What I would like to do is use a Stream Deck button to toggle through 3 combinations of
Main Counter/SubCounter/Timeline Grid:
Min:Sec/Bars|Beats/1 millisecond gridlines
Bars|Beats/Min:Sec/1 bar gridlines
Bars|Beats/Min:Sec/quarter note gridlines
Perhaps the Main Counter and Timeline Grid would have to be toggled separately, thus using two Stream Deck buttons rather than just one.
Has anybody already done this? Could I have access to your script to use it or to attempt to modify it?
Sincere Thanks!
Kitch Membery @Kitch2022-08-08 21:38:14.764ZHi @Gerry_Valenti,
This should do the trick.
const settings = { option1: { mainCounterMode: "Min:Secs", subCounterMode: "Bars|Beats", timelineGridValue: " 0:00.001", timelineGridMenuItem: "1 msec" }, option2: { mainCounterMode: "Bars|Beats", subCounterMode: "Min:Secs", timelineGridValue: " 1| 0| 000", timelineGridMenuItem: "1 bar" }, option3: { mainCounterMode: "Bars|Beats", subCounterMode: "Min:Secs", timelineGridValue: " 0| 1| 000", timelineGridMenuItem: "1/4 note" }, } function setMainCounterMode({ mode }) { sf.ui.proTools.getMenuItem('View', 'Main Counter', mode).elementClick(); } function setSubCounterMode({ mode }) { sf.ui.proTools.mainWindow.counterDisplay.buttons.whoseTitle.is("Sub Counter selector").first.popupMenuSelect({ menuPath: [mode], }); } function setTimelineGridValue({ value }) { sf.ui.proTools.mainWindow.gridNudgeCluster.popupButtons.first.popupMenuSelect({ menuPath: [value] }) } function main() { //Activate and Invalidate main window sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const subCounterText = sf.ui.proTools.mainWindow.counterDisplay.children.whoseRole.is("AXStaticText").whoseValue.is("Sub").first; const mainCounterSelectorPopup = sf.ui.proTools.mainWindow.counterDisplay.buttons.whoseTitle.is("Main Counter selector").first; //Ensure the Sub Counter is visible if (!subCounterText.exists) { mainCounterSelectorPopup.popupMenuSelect({ menuPath: ["Show Sub Counter"], }); } //Store the Current Settings const currentSettings = { timelineGridValue: sf.ui.proTools.mainWindow.gridNudgeCluster.popupButtons.first.value.invalidate().value, } if (currentSettings.timelineGridValue === settings.option1.timelineGridValue) { //Switch to option 2 settings setMainCounterMode({ mode: settings.option2.mainCounterMode }); setSubCounterMode({ mode: settings.option2.subCounterMode }); setTimelineGridValue({ value: settings.option2.timelineGridMenuItem }); } else if (currentSettings.timelineGridValue === settings.option2.timelineGridValue) { //Switch to option 3 settings setMainCounterMode({ mode: settings.option3.mainCounterMode }); setSubCounterMode({ mode: settings.option3.subCounterMode }); setTimelineGridValue({ value: settings.option3.timelineGridMenuItem }); } else { //Switch to option 1 settings setMainCounterMode({ mode: settings.option1.mainCounterMode }); setSubCounterMode({ mode: settings.option1.subCounterMode }); setTimelineGridValue({ value: settings.option1.timelineGridMenuItem }); } } main();Note: I have the Grid set to follow Main Time Scale. so that it does the mode switching automatically.
I hope that helps :-)
Rock on!- KKevin Madigan @kevin_madigan
Came across this one and thought it might be quite useful but am getting an error in Line 34
Could not click popup menu item (Toggle Main Counter: Line 34)
Could not find menu item with name: 1 msec
Kitch Membery @Kitch2026-03-07 00:08:20.261ZThat script is very out of date and has a missing piece, so I dusted it off and made it SFX compatible.
Take this for a spin.
if (sf.ui.useSfx) sf.ui.useSfx(); const OPTIONS = [ { mainCounterMode: "Min:Secs", subCounterMode: "Bars|Beats", timelineGridValue: " 0:00.001", timelineGridMenuItem: "1 msec" }, { mainCounterMode: "Bars|Beats", subCounterMode: "Min:Secs", timelineGridValue: " 1| 0| 000", timelineGridMenuItem: "1 bar" }, { mainCounterMode: "Bars|Beats", subCounterMode: "Min:Secs", timelineGridValue: " 0| 1| 000", timelineGridMenuItem: "1/4 note" }, ]; function main() { if (!sf.ui.proTools.isSfxApplication) sf.ui.proTools.appActivateMainWindow(); const mainWindow = sf.ui.proTools.mainWindow; mainWindow.invalidate(); const counterDisplay = mainWindow.counterDisplay; const gridNudgeCluster = mainWindow.gridNudgeCluster; const setMainCounterMode = (mode) => sf.ui.proTools.getMenuItem('View', 'Main Counter', mode).elementClick(); const setSubCounterMode = (mode) => counterDisplay.buttons.whoseTitle.is("Sub Counter selector").first.popupMenuSelect({ menuPath: [mode] }); const getGridValuePopup = () => gridNudgeCluster.popupButtons.whoseTitle.is("Grid Value").first; const setTimelineGrid = (value) => getGridValuePopup().popupMenuSelect({ menuPath: [value] }); const applyOption = (option) => { setMainCounterMode(option.mainCounterMode); setTimelineGrid(option.mainCounterMode); setSubCounterMode(option.subCounterMode); setTimelineGrid(option.timelineGridMenuItem); }; // Ensure Sub Counter is visible const subCounterText = counterDisplay.children.whoseRole.is("AXStaticText").whoseValue.is("Sub").first; if (!subCounterText.exists) { counterDisplay.buttons.whoseTitle.is("Main Counter selector").first.popupMenuSelect({ menuPath: ["Show Sub Counter"], }); } // Cycle to next option const currentGridValue = getGridValuePopup().value.invalidate().value; const currentIndex = OPTIONS.findIndex((o) => o.timelineGridValue === currentGridValue); const nextOption = OPTIONS[(currentIndex + 1) % OPTIONS.length]; applyOption(nextOption); } main();Let me know if it works for you. :-)
- KKevin Madigan @kevin_madigan
Thanks. Seems to be better but getting
06.03.2026 16:27:11.82 [Backend]: !! Command Error: Toggle Main Counter - Not working [user:clu4ucxpt002rkj10hzi2bvll:cmmfdelnm0000eff5jzjtn9lj]:
The menu item was not found in the popup menu (Toggle Main Counter - Not working: Line 42)Appreciate the help on this and realize is a vintage one!! :)
Kitch Membery @Kitch2026-03-07 01:56:40.611ZThanks for letting me know. Unfortunatly I'm unable to reproduce the issue.
Is it changing any of the values at all? And is there a specific set of values it's failing on?
Perhaps you could provide a screen recording.Thanks in advance.
- KKevin Madigan @kevin_madigan
May be that it's a beta version of Pro Tools? Mostly works.

Kitch Membery @Kitch2026-03-09 22:34:06.307ZAre you able to open the latest non-beta released build of Pro Tools to see if it works?
To troubleshoot the issue further, I need to know which parameters are failing.
The best way to test this would be to manually set the parameters to the first group of settings and then try using the command. Afterward, repeat with the next set of settings to identify where the failure occurs.You could also test the functions one by one, by commenting out each function call in the
applyOptionsone at a time.eg. Test setting the main counter
const applyOption = (option) => { setMainCounterMode(option.mainCounterMode); // setTimelineGrid(option.mainCounterMode); // setSubCounterMode(option.subCounterMode); // setTimelineGrid(option.timelineGridMenuItem); };Then test setting the timeline grid...
const applyOption = (option) => { // setMainCounterMode(option.mainCounterMode); setTimelineGrid(option.mainCounterMode); // setSubCounterMode(option.subCounterMode); // setTimelineGrid(option.timelineGridMenuItem); };etc.
Let me know what you find. :-)
- GIn reply toGerry_Valenti⬆:Gerry Valenti @Gerry_Valenti
It works great! Simple task, but this combines multiple button-pushes into just one.
Thank you so much...