No internet connection
  1. Home
  2. Packages
  3. Logic X Color Deck (XL)

Trouble ensuring that the color palette is visible (as well as selecting other Logic Menu Items)

By Alexandre Hirlinger @Alexandre_Hirlinger
    2021-11-10 16:17:41.630Z

    Hello! I'm reposting this question under this packages forum, but I am having a hard time getting SF to recognize a lot of menu items within a variety of different programs, Logic being one of them. This code is a great example of that issue.

    For whatever reason, SF doesn’t seem to like certain menu’s, or menu items when using the “click menu item” macro action. I triple check to make sure that the menu and the menu items are typed exactly the same (including case), but SoundFlow still can’t seem to find the menu items.

    What’s odd is that Keyboard Maestro seems to do fine with these same menu items. What’s even weirder is that when I copy and paste the exact text for the menu title path from Keyboard Maestro’s “menu select” command into SoundFlow’s same command, the command will work for a couple times, but then fail when I come back to use the command at a later date. The same thing happens if I manually type the menu title path into this script (in this example, I type "Show Colors into the 13th line of code) - it will work a couple times, but then stop working shortly after.

    Therefore, by default, this script fails to ensure that the color palette is visible, because it cannot select the menu item “show colors.” However, like I mentioned, if I go into the code for a specific script and simply type in “View”, “Show Colors”, the command works a couple times and then continues to fail, shortly after.

    I have included a couple screenshots of the logs after I try and run the script, as well as an example of one of the scripts that I am using (I made editable copies of the scripts in this package with colors that are tailored to my use-cases)

    Any help would be greatly appreciated. Thanks!

    var colorX = 1;
    var colorY = 1;
    
    function ensureColorPaletteIsOpen() {
        var logic = sf.ui.app('com.apple.logic10');
    
        //Open Logic Pro X
        logic.appActivateMainWindow();
    
        //If the Color Palette is not open, Click menu item View -> Show Colors
        if (!logic.windows.whoseTitle.is('Color').exists) {
            logic.menuClick({
                menuPath: ["View", "Show Colors"],
            });
        }
    }
    
    function selectColor(colorX, colorY) {
        const colorLineIndices = [98, 73, 1, 25, 49];
        var colorButtonIndex = colorLineIndices[colorY] + colorX - 2;
    
        //Select Color
        sf.ui.app("com.apple.logic10").windows.whoseTitle.is("Color").first.groups.whoseDescription.is("").first.groups.whoseDescription.is("(null) contents").first.buttons.allItems[56].elementClick();
    }
    
    ensureColorPaletteIsOpen();
    selectColor(colorX, colorY);
    
    Solved in post #4, click to view
    • 3 replies
    1. Hi Alexandre,

      Yea this is definitely a weird issue. I don't own Logic myself so it'll be hard to troubleshoot this particular issue for me.

      What are the other apps where you're having trouble with this? Perhaps we can use that to troubleshoot. Not sure what would be causing this so we'd need to dive deeper.

      1. Hey Christian! I believe Kitch is trying to help me out with this specific script in some other threads, but it does seem to be odd. As I've mentioned to him, it works for a little while if I manually type in "View" and "Show Colors" into the script, but then it eventually begins to fail; and like I also mentioned KM seems to handle Logic's menu's fine.

        What I've also noticed is that the script works if the "view" menu was the last menu that I selected; however, if I have more recently navigated to a different menu (i.e. file menu, edit menu, etc.) then it fails.

        There have been a number of applications where I have experienced a similar issue but I can't remember most instances off the top of my head. The next time one arrises, I'll try and remember to update this thread. The only one that comes to mind is trying to scrip the Play/Pause button in Spotify under the menu Playback -> Play. SF seemed to have issues recognizing this menu item as well for some reason.

        This menu item is dynamic (like it changes from play to pause, or vice versa, depending on the active state). The same thing is true for the Logic Color Palette Menu (it changes from "Show Colors" to "Hide Colors". Could this have anything to do with SF having issues?

        1. It sounds like you guys found a compromise for now in the other thread, so let's keep the discussion there going forward to keep it simpler to follow the progress :)

          Reply1 LikeSolution