- Christian Scheuer @chrscheuer2019-10-22 16:09:14.408Z
Will's original question moved here:
- WWill Reynolds @Will_Reynolds
Hey guys,
Hope alls good - i am trying to do this in logic but am having no luck because there is no pop up window - any thoughts?
I have done a really basic thing by getting into the rename tracks but want to retype the text in the field as capital.
var logic = sf.ui.app('com.apple.logic10'); sf.keyboard.press({ keys: 'shift+return' }); sf.keyboard.press({ keys: 'caps' });
Christian Scheuer @chrscheuer2019-10-22 10:48:34.466Z
Hi Will
Can you show us the full code? What is the text that you're trying to type in?
- WWill Reynolds @Will_Reynolds
bold textHey @chrscheuer I have gotten this far but basically want it to repeat the capitalisation until all tracks have been done -
I'm also looking to get it to search for a specific word like 'Kick' when the track might be called ' 07436Kick&83' and rename it just to 'KICK' and then color accordingly.var logic = sf.ui.app('com.apple.logic10'); sf.keyboard.press({ keys: 'shift+return' }); sf.keyboard.press({ keys: 'cmd+c' }); var text = sf.clipboard.getText().text; var textInAllCaps = text.toUpperCase(); sf.keyboard.type({ text: textInAllCaps }); sf.keyboard.press({ keys: 'tab' });
Thanks
Christian Scheuer @chrscheuer2019-10-22 16:14:45.601Z
This script will walk through all your tracks renaming them to upper case one by one:
var logic = sf.ui.app('com.apple.logic10'); var trackHeaders = logic.mainWindow.groups.whoseDescription.is('Tracks').first.groups.whoseDescription.is('Tracks').allItems[1].splitGroups.first.splitGroups.allItems[1].scrollAreas.first.groups.whoseDescription.is('Tracks header').first.groups; trackHeaders.map(trackHeader => { trackHeader.elementClick(); var name = trackHeader.getString("AXDescription").match(/“(.*)”/)[1]; logic.getMenuItem('Track', 'Rename Track').elementClick(); sf.keyboard.type({ text: name.toUpperCase() }); sf.keyboard.press({ keys: 'enter' }); });
- WWill Reynolds @Will_Reynolds
Hey Chris,
Thanks so much for that i really appreciate it! I am having trouble to get this working. I've noticed its been added to the Logic Pro X shortcuts so tried to download it from there as well and am having no luck. Any ideas?
Thanks so much in advance
W
Christian Scheuer @chrscheuer2019-10-22 17:22:24.211Z
Hi Will.
Can you elaborate a little bit more on how you're having no luck with it?
What happens when you execute it?
Do you get any errors?Christian Scheuer @chrscheuer2019-10-22 17:24:38.068Z
The reason by the way might be that we're on different Logic versions. This is working here on 10.3.3. I asked you in a previous question about your version but I don't think I received a reply. What version of Logic are you on?
To help you with this, any information you can give me will help me help you.- WWill Reynolds @Will_Reynolds
Hey Chris,
Thanks for that! I'm on the latest version - 10.4.7 - It seems that its not running - I've tried assigning different commands to it but having no luck unfortunately - you are right it could totally be a version issue. I get no errors at all from what i can see it just seems that it does'nt execute. Probably something I'm doing wrong over here.
Thanks
W
Christian Scheuer @chrscheuer2019-10-24 08:10:11.605Z
Right, that definitely sounds like a version issue. We'll probably have to wait for someone with more script experience to have Logic 10.4 to help us here
Kitch Membery @Kitch2020-01-22 22:31:31.594Z
I have Logic 10.4.8 running here... and I was able to get the script working with two small changes.
Please note, the script only works if you have the absolute first track selected in the edit window, otherwise it will mislabel the tracks.
The changes were as follows;
- In the "trackHeaders" variable line I changed
first.groups;
tofirst.children;
- I added a down key press to the last line of the script
sf.keyboard.press({ keys: 'enter,down' });
so the script would move to the next track.
Here is the script;
var logic = sf.ui.app('com.apple.logic10'); var trackHeaders = logic.mainWindow.groups.whoseDescription.is('Tracks').first.groups.whoseDescription.is('Tracks').allItems[1].splitGroups.first.splitGroups.allItems[1].scrollAreas.first.groups.whoseDescription.is('Tracks header').first.children; trackHeaders.map(trackHeader => { trackHeader.elementClick(); var name = trackHeader.getString("AXDescription").match(/“(.*)”/)[1]; logic.getMenuItem('Track', 'Rename Track').elementClick(); sf.keyboard.type({ text: name.toUpperCase() }); sf.keyboard.press({ keys: 'enter,down' }); });
Hope that helps. :-)
Christian Scheuer @chrscheuer2020-01-27 02:37:34.957Z
Awesome Kitch - great work!
Kitch Membery @Kitch2020-01-27 03:25:56.237Z
I tried with no success to map the "selected tracks" instead of all the tracks to be renamed to uppercase as the script only works if you have the absolute first track selected in the edit/arrange window, otherwise it mislabels the tracks.
Is there a way to do that? (No rush on this one) but it would be nice to know, to be able to apply the idea to other scripts in logic.
Jesper Ankarfeldt @JesperA2020-02-05 04:12:45.302Z
Did you figure this one out @Kitch.
Else I think this should do it:var logic = sf.ui.app('com.apple.logic10'); sf.clipboard.clear(); logic.getMenuItem('Track', 'Rename Track').elementClick(); logic.getMenuItem('Edit', 'Copy').elementClick(); var trackName = sf.clipboard.waitForText().text; sf.keyboard.type({ text: trackName.toUpperCase() }); sf.keyboard.press({ keys: 'enter' })
Kitch Membery @Kitch2020-02-05 05:20:05.758Z
Thanks again Jesper,
I did get it working in this post; https://forum.soundflow.org/-1174#post-12
The only remaining issue is that I can't work out how to select the Logic Pro session's first track (By Track Label: Track 1) via javascript at the beginning of the script.
- In reply toKitch⬆:
Jesper Ankarfeldt @JesperA2020-02-06 19:48:09.029Z
Ah yeah I read it wrong, thought you asked for renaming selected track only.
I looked a little at the arrangement window of Logic, and it is a bit difficult to map, and make sure you get the first element, because depending on what side and bottom panels you have open, the UI texts changes, which mean that the above script might also not work, if you don't have the same panels open.I'll try to look a little more at it at a later point, and see if I can make a clever mapping of the arrangement window. If that's done, it will be easy to select the first track or tracks with a specific name...
Kitch Membery @Kitch2020-02-06 19:52:54.008Z
Nice, Thanks mate. :-)
- RRinus Aarts @Rinus_Aarts
I made a small improvement, with this script it's not needed to select the first track:
var logic = sf.ui.app('com.apple.logic10'); var trackHeaders = logic.mainWindow.groups.whoseDescription.is('Tracks').first.groups.whoseDescription.is('Tracks').allItems[1].splitGroups.first.splitGroups.allItems[1].scrollAreas.first.groups.whoseDescription.is('Tracks header').first.children; trackHeaders.map(trackHeader => { // click on the track trackHeader.textFields.first.mouseClickElement(); // rename the track logic.getMenuItem('Track', 'Rename Track').elementClick(); var name = trackHeader.getString("AXDescription").match(/“(.*)”/)[1]; sf.keyboard.type({ text: name.toUpperCase() }); });
- GGraham Archer @Graham_Archer
Hey @Kitch and @Rinus_Aarts this is great, but I'm finding that it only works for tracks that are visible in the arrange window. If I have tracks below the last visible track, the script tries to rename the last visible track with all the track names that are not visible. It just needs to move the track selection down through each track in the session. Is there an easy way to do this?
Or am I using the script incorrectly?Any help would be much appreciated!
Kitch Membery @Kitch2025-04-17 21:21:04.079Z
Ahh yes, I can see how that would happen. I think I know a way to do it. I shall take a look at this early next week :-)
Bump this thread if you don't hear from me.
- In reply toGraham_Archer⬆:
Kitch Membery @Kitch2025-04-17 21:46:42.304Z
It looks like I already have a script for this...
Please note, before running the script, there are a couple of requirements (otherwise the script will not work as expected). The track headers must be customized to have "Track numbers" visible and "Track Control Surface Bars" hidden.
Here is the script.
// Requires track numbers to be visible in the Logic Pro Arrange window. // Requires Track Control Surface Bars to be hidden const logic = sf.ui.logic; logic.appActivateMainWindow(); logic.invalidate(); function getSelectedTracks() { const trackHeadersGroup = logic.mainWindow.trackHeadersGroup; return trackHeadersGroup.getElements('AXSelectedChildren'); } function getTrackName(track) { const trackDescription = track.getString("AXDescription"); const trackName = trackDescription.match(/“([^”]+)”/)[1]; return trackName; } function focusTrack(track) { const hasFocusBtn = track.radioButtons.first; hasFocusBtn.elementSetAttributeValue({ attributeName: "AXFocused", attributeValue: true }); hasFocusBtn.elementClick(); } function renameTrack(track, newTrackName) { const nameTextField = track.textFields.first; nameTextField.elementSetAttributeValue({ attributeName: "AXFocused", attributeValue: true }); nameTextField.elementSetTextFieldWithAreaValue({ value: newTrackName }); nameTextField.elementClick({ actionName: "AXConfirm" }); } function main() { const selectedTracks = getSelectedTracks(); const firstSelectedTrack = selectedTracks[0] // Do for each selected Track selectedTracks.forEach(track => { const oldTrackName = getTrackName(track) // Clean the track name const newTrackName = oldTrackName.toUpperCase(); // Replace track names if they have changed if (oldTrackName !== newTrackName) { // Focus track (Important The track needs to be in view for the element's text to be changed) focusTrack(track); // Rename new track name renameTrack(track, newTrackName); // Re focus track (Removes focus from the text field) focusTrack(track); } }); // Refocus first selected track focusTrack(firstSelectedTrack); } main();
- GGraham Archer @Graham_Archer
Hey @Kitch, this is great! I just added:
focusTrack(selectedTracks[0]);
at the top of the main function as I found that if I had a large number of selected tracks and I was at the bottom of that selection (so the first selected track was not visible) the script wouldn't run.
Thanks so much!
Kitch Membery @Kitch2025-04-22 17:41:55.484Z
Awesome! Glad it's working for you. And good sleuthing! :-)
- In the "trackHeaders" variable line I changed