No internet connection
  1. Home
  2. How to

Logic Pro X submenu selection?

By Brad Cole @Brad_Cole
    2020-03-17 17:13:06.864Z

    Hi Christian, My friend Ron Aston has introduced me to Soundflow, and I am learning it pretty well so far. However, I am writing a macro to 1. open the MIDI transform window in Logic (command-9), click on a pulldown menu within the transform window (Presets:), choose one of the presets, press the "operate" button, and close the transform window. I can get the macro to open the transform window, and open the pulldown menu. Cannot figure out how to choose a preset within that pulldown menu. (Apologies if this is blindingly simple, and I can't figure it out myself!) Any help will be greatly appreciated.

    Also, anyone out there who has created a package for Logic Pro X and would like to sell it, please let me know.

    Thanks for your attention,

    Brad Cole
    www.thecolemine.com

    Solved in post #5, click to view
    • 28 replies

    There are 28 replies. Estimated reading time: 15 minutes

    1. Hi Brad,

      Great to have you on board. I'll CC @Kitch and @JesperA here since I know they have written scripts/macros for Logic before (I have an old version of Logic so we have had issues with my macros working for other users).

      1. Generally speaking though - to click popup menus like this you'll need the action "Open & Select Item in Popup Menu".

        You can watch how automating popup menus can be done (albeit in Pro Tools) here:
        https://www.youtube.com/watch?v=20ECpTUy_jk

        1. BBrad Cole @Brad_Cole
            2020-03-18 15:33:56.927Z

            Thank you, Christian. Nice to be onboard here. I tried that routine first, and it only opened the submenu, without choosing the submenu item.

            Looks like the scripts below might be the answer.

            BC

            1. In reply tochrscheuer:
              BBrad Cole @Brad_Cole
                2020-03-18 17:28:37.201Z

                Hi Christian, I have watched this one several times, and it did help me get started in designing the macro. Somehow, this Logic pulldown menu does not operate like a Pro Tools one. I will keep trying things.....
                BC

                1. Gotcha, that makes sense - thanks for letting me know. We may have to adjust our internal code to make sure it works for Logic as well.

            2. In reply toBrad_Cole:
              Kitch Membery @Kitch2020-03-18 07:37:22.671Z

              Hi Brad,

              Will see what I can do :-)

              K

              1. In reply toBrad_Cole:
                Kitch Membery @Kitch2020-03-18 07:57:12.236Z

                Hi Brad,

                This should do it. All you need to do is change the Preset name variable in the code

                ie //Preset Name var presetName = "Half Speed";

                //Preset Name
                var presetName = "Half Speed";
                
                var logic = sf.ui.app('com.apple.logic10');
                
                //Activate Logic Pro X
                logic.appActivate();
                
                //Open MIDI Transform Window
                logic.menuClick({
                    menuPath: ["Window","Open MIDI Transform"],
                });
                
                //Wait for MIDI Transform Window
                logic.windows.first.elementWaitFor();
                
                //Enter text into preset Search field
                logic.windows.first.textFields.first.elementSetTextAreaValue({
                    value: presetName,
                });
                
                //Press Operate
                logic.windows.first.buttons.whoseTitle.is('Select and Operate').first.elementClick();
                
                //Close MIDI Transform Window
                logic.windows.first.windowClose();
                

                Hope that helps
                Rock on!!

                Reply2 LikesSolution
                1. Ha, didn't see you had answered :)

                  1. In reply toKitch:

                    And nice that you can just write in the preset name, instead of selecting it from the dropdown. Didn't know that.

                    1. Kitch Membery @Kitch2020-03-18 08:27:16.816Z

                      Hi @JesperA!

                      I worked out you could type in the preset by accident when I was ui picking the dropdown menu.

                      Fun little script I'll get a bunch of use out of it myself.

                      K

                      1. Yeah. I don't really use Logic anymore as I'm in Nuendo.
                        In Nuendo the Logical Editor is the equivalent of the Tranformer Window in Logic.

                        To me this functionality is the bread and butter for MIDI manipulation.
                        But the problem with Logic was/is that you can't properly put a preset as a key command.
                        But SF solves that. You could even make presets on the fly, putting in different values etc :) So cool!

                  2. In reply toBrad_Cole:

                    Hi Brad.

                    As the window doesn't have a specific title, just make sure it's the one that's in focus. Then you can:

                    • Select a specific preset. Here the one called Crescendo:
                    sf.ui.app('com.apple.logic10').focusedWindow.popupMenuSelect({ relativePosition: { x: 295, y: 45 },menuPath: ['Crescendo'] });
                    
                    • you could also do this within a Macro. If you convert this macro it will be the exact same thing as the script above:

                    --

                    • You could also get the different presets in in the menu as an array:
                    var presets = sf.ui.app('com.apple.logic10').focusedWindow.popupMenuFetchAllItems({ relativePosition: { x: 295, y: 45 } }).menuItems;
                    log(presets.join(','))
                    

                    --

                    • When you wanna apply the script you would use:
                    sf.ui.app('com.apple.logic10').focusedWindow.buttons.whoseTitle.is('Select and Operate').first.elementClick();
                    
                    1. @Oscar_Fogelstrom FYI - more and more Logic scripts are arriving.

                      1. In reply toJesperA:
                        BBrad Cole @Brad_Cole
                          2020-03-18 15:37:00.413Z

                          Thank you Jesper, very much. The X/Y values indicated are the coordinates of the button that opens the pulldown window?

                          BC

                          1. Yes, that's exactly what it is :)

                            I find that using the MacOs build in screen shot function with cmd+shift+4.
                            Then when you drag there'll be a small text showing the X/Y distance.
                            Don't know if that's was well enough explained

                            1. BBrad Cole @Brad_Cole
                                2020-03-20 15:12:29.758Z

                                Thanks, J. I already do that, but with two screens, I am not sure that the X/Y coördinates represent the relationship of the cursor location to the targeted window.

                                So far, all attempts, including some of the scripts posted here, only open the pulldown window without making the next selection.

                                But that is better than nothing, of course.

                                Best, BC.....

                                1. Kitch Membery @Kitch2020-03-20 21:06:43.315Z

                                  Hi Brad,

                                  Did you try the script I added 3 days ago? It should work even if the window is on a second screen. Important to note though, with this kind of automation the window being automated needs to be visible for it to work.

                                  The dropdown menu in the MIDI transform window does not seem to respond like a regular dropdown menu so it's best to use the text field to enter the name of the preset.

                                  Kitch

                                  1. BBrad Cole @Brad_Cole
                                      2020-03-25 15:29:54.525Z

                                      Hi Kitch, Yes I did try it, but it only gets as far as opening the pulldown window, which is where I got to with every other attempt. So, for now anyway, I'll leave it that way. I made a second macro that performs the operation, and closes the window.

                                      Thanks so much for your kind help.

                                      Best, BC

                                      1. Kitch Membery @Kitch2020-03-25 18:42:47.311Z

                                        Hi Brad,

                                        Sorry you couldn't get my script working. Is the following script the one you are using?

                                        //Preset Name
                                        var presetName = "ADD PRESET NAME HERE";
                                        
                                        var logic = sf.ui.app('com.apple.logic10');
                                        
                                        //Activate Logic Pro X
                                        logic.appActivate();
                                        
                                        //Open MIDI Transform Window
                                        logic.menuClick({
                                            menuPath: ["Window","Open MIDI Transform"],
                                        });
                                        
                                        //Wait for MIDI Transform Window
                                        logic.windows.first.elementWaitFor();
                                        
                                        //Enter text into preset Search field
                                        logic.windows.first.textFields.first.elementSetTextAreaValue({
                                            value: presetName,
                                        });
                                        
                                        //Press Operate
                                        logic.windows.first.buttons.whoseTitle.is('Select and Operate').first.elementClick();
                                        
                                        //Close MIDI Transform Window
                                        logic.windows.first.windowClose();
                                        

                                        This does not use x,y coordinates, it uses the preset text field in the MIDI Transform Window to enter the preset name.

                                        All you have to do is change the second line preset name to your preset name and it should work.

                                        I'm not at my main computer (which has 2 screens) but I'll try it later.

                                        Rock on
                                        Kitch

                                        1. JJon Newell @Jon_Newell
                                            2020-05-30 04:37:18.164Z

                                            I realize I'm late to the party here, but I am trying to get the same thing working.

                                            Your script works beautifully the first time, but if the script is used again to trigger a different preset it doesn't quite work.

                                            In my example I used your script set to "Humanize", then a duplicate of the script set to "Fixed Velocity". When the Humanize script is used on a fresh Logic session it works, but when the Fixed Velocity script is used afterwards, the results are the Humanize script again.

                                            I believe the problem is that if Logic's Transform window is used a second time, it leaves the search field full of the terms last entered. When SF enters the new name in the search field it appends it to the old search terms. Logic then, unable to resolve the name, defaults back to the previously used Transform preset.

                                            Any ideas on how to get around this?

                                            Thanks for your help!

                                            -Jon

                                            1. Kitch Membery @Kitch2020-05-30 07:03:16.672Z

                                              This should fix it Jon;

                                              //Preset Name
                                              var presetName = "Preset Name Here";
                                              
                                              var logic = sf.ui.app('com.apple.logic10');
                                              
                                              //Activate Logic Pro X
                                              logic.appActivate();
                                              
                                              //Open MIDI Transform Window
                                              logic.menuClick({
                                                  menuPath: ["Window","Open MIDI Transform"],
                                              });
                                              
                                              //Wait for MIDI Transform Window
                                              logic.windows.first.elementWaitFor();
                                              
                                              //Select Preset from Popup Menu
                                              logic.focusedWindow.popupMenuSelect({ relativePosition: { x: 295, y: 45 },menuPath: [presetName] });
                                              
                                              //Press Operate
                                              logic.windows.first.buttons.whoseTitle.is('Select and Operate').first.elementClick();
                                              
                                              //Close MIDI Transform Window
                                              logic.windows.first.windowClose();
                                              

                                              Let me know if it works for you. :-)

                                              1. Kitch Membery @Kitch2020-05-30 07:17:46.954Z

                                                Or a version as a re-usable function;

                                                function setMidiTransformPreset(presetName) {
                                                    var logic = sf.ui.app('com.apple.logic10');
                                                    logic.appActivate();
                                                    logic.menuClick({ menuPath: ["Window", "Open MIDI Transform"], });
                                                    logic.windows.first.elementWaitFor();
                                                    logic.windows.first.popupMenuSelect({ relativePosition: { x: 295, y: 45 }, menuPath: [presetName] });
                                                    logic.windows.first.buttons.whoseTitle.is('Select and Operate').first.elementClick();
                                                    logic.windows.first.windowClose();
                                                }
                                                
                                                setMidiTransformPreset('Preset Name Here');
                                                
                                                1. JJon Newell @Jon_Newell
                                                    2020-05-30 13:58:03.265Z2020-05-30 15:00:18.811Z

                                                    Wow!

                                                    You just solved a huge workflow wish for me. Thank you so much!

                                                    Edit: for anyone who finds this later, I changed:

                                                    logic.windows.first.buttons.whoseTitle.is('Select and Operate').first.elementClick();
                                                    to
                                                    logic.windows.first.buttons.whoseTitle.is('Operate Only').first.elementClick();

                                                    so that the transformation is performed only on the notes I have selected prior to triggering the macro

                                                    1. Kitch Membery @Kitch2020-05-30 16:19:37.923Z

                                                      Awesome!

                                2. B
                                  In reply toBrad_Cole:
                                  Brad Cole @Brad_Cole
                                    2020-03-18 15:32:07.993Z

                                    Thank you, kind sirs everywhere. I very much appreciate the good suggestions here, and especially the sense of brotherhood among this community.

                                    I'll give these a try today, as I "shelter in place" in the ColeMine. One small upside to the current crisis: plenty of time to work on technique!

                                    I've no experience with Javascript, so perhaps it is time to learn!

                                    Best, BC

                                    1. Kitch Membery @Kitch2020-03-18 20:50:01.303Z

                                      You are welcome mate! And yes it's a great time to learn Javascript during this period of isolation.

                                      BTW, what are you using Logic for... Composing? Music Production? With the SoundFlow community growing so quickly its good to know who is using Logic Pro X as their main DAW.

                                    2. In reply toBrad_Cole:
                                      Kitch Membery @Kitch2024-03-13 23:12:05.754Z

                                      Hi @Brad_Cole

                                      I just thought I'd give you a heads up in case you were not aware, recently we added an Official Logic Pro package to SoundFlow that includes, Plugin, Instrument, MIDI FX, and Send loaders + much more. The package is available in the SoundFlow Store and requires Logic Pro 10.8 and above, and SoundFlow 5.7.0.

                                      If you're interested, we'll be holding a webinar tomorrow Thursday 14th March at 11 am PST. If you are interested, be sure to register at the following link:

                                      https://soundflow.org/events/2024-03-logic-pro-webinar

                                      I hope you can attend. :-)

                                      1. M
                                        In reply toBrad_Cole:
                                        Mark Murphy @Mark_Murphy
                                          2025-02-27 22:54:35.372Z

                                          So I'd dearly love to get this working but evertime I try it I get an error:
                                          Delete Short Notes failed
                                          Could not open popup menu (Delete Short Notes:
                                          Line 18) I'm trying to load a user preset within the menu.

                                          Many thanks,

                                          Mark.