By Kitch Membery @Kitch2019-10-26 07:18:43.962Z
Hi @Will_Reynolds,
I saw you started a chat 4 days ago about accessing exact colors in logic. I too wanted to work this out so I wrote a script and thought I'd share it. Its working for me in Logic Pro X 10.4.6 :-)
//This Script is for picking colors with Logic Pro X's Color Palette
//There are 4 rows with 24 colors in each.
//Adjust the "colorLine" and "colorNumber" variables to your prefered color.
//For default color set both the "colorLine" and "colorNumber" variables to 0
var colorLine = 0
var colorNumber = 0
//Open Logic Pro X
sf.ui.app('com.apple.logic10').appActivateMainWindow();
//If the Color Palette is not open, Click menu item View -> Show Colors
if (!sf.ui.app('com.apple.logic10').windows.whoseTitle.is('Color').exists) {
sf.ui.app('com.apple.logic10').menuClick({
menuPath: ["View", "Show Colors"],
});
}
//Math for colors
//Line 1 Colors range from 73 - 96
if (colorLine == 1) { var colorNumberNew = colorNumber + 73}
//Line 1 Colors range from 1 - 24
if (colorLine == 2) { var colorNumberNew = colorNumber + 1}
//Line 3 Colors range from 25 - 48
if (colorLine == 3) { var colorNumberNew = colorNumber + 25}
//Line 3 Colors range from 49 - 72
if (colorLine == 4) { var colorNumberNew = colorNumber + 49}
//default color = 97
if (colorLine == 0) { var colorNumberNew = colorNumber + 98}
//Select Color
sf.ui.app('com.apple.logic10').windows.whoseTitle.is('Color').first.groups.first.groups.first.buttons.allItems[colorNumberNew-2].elementClick();
I figured I'd post it here for reference. If anyone has a better way feel free to chime in.
Kitch
- Christian Scheuer @chrscheuer2019-10-27 11:41:58.488Z
Nice work @Kitch!
Christian Scheuer @chrscheuer2019-10-27 11:47:40.911Z
Here's my take on adapting/refactoring your code a bit - just for inspiration:
var colorX = 0; var colorY = 0; 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.first.groups.first.buttons.allItems[colorButtonIndex].elementClick(); } ensureColorPaletteIsOpen(); selectColor(colorX, colorY);
Kitch Membery @Kitch2019-10-27 17:58:37.706Z
Much better! Thanks. :-)