how to define a specific window point and assign a color palette trigger

54 Views Asked by At

There are some GUI elements/buttons in Logic pro X that don't have a state parameter (value = nil see appendix) accessebility insperctor

and so I need to help to create an applescript to check the color palette of that GUI-button for subsequent assignments of MIDI messages to an external controller. while there is one idea - use the button color change parameter for the trigger (arm-state is blue, disarmstate is gray)... and how to locate this mapping to button-element? (I stopped coding at this point...

Have any ideas?

    tell application "Logic Pro X" to activate
delay 1
tell application "System Events"
    set projectContent to entire contents of first application process whose its frontmost is true
    set project to item 2 of projectContent -- and first UI element is window
    tell process "Logic Pro X"
        tell project --  the specific/valid your own project name to proper script work
(*
                the following lines find the smart control panel, by looking for
                 stable features of their respective toolbars. the first looks for the 
                 'Compare' button, the second for the 'Arpeggiator' checkbox. 
                 the doubled 'whose' queries look confusing, but basically they say "Find the group 
                 whose first group is a toolbar, whose last (slider's/radiobutton's) description is...  
                 Once we have those, we can reliably find these area, regardless of whether other groups 
                 are opened or closed"
*)
            try
                set smartControl_panel to first group whose its (first UI element whose role description is "toolbar")'s last checkbox's description is "Arpeggiator"
            on error
                keystroke "b" -- if smart control panel is not open, so open it by LPX key-command keystroke "b"
                delay 2
                set smartControl_panel to first group whose its (first UI element whose role description is "toolbar")'s first button's description is "Compare"
            end try
            tell smartControl_panel
                tell first group
                    log (get description of every UI element) -- log a list of all the visible UI elements
                    set compare_button to first UI element whose role description is "button" and description is "Compare"
                    log (get position of compare_button) -- log current position state of the compare_button
                    set x to (item 1 of position) + 10
                    set y to (item 2 of position) + 10
                    set compare_state to {x, y}

(* That is my problem with callback "collor button check in stay-open application:

                    -- set buttonCheck(compare_state, x, y)
                if buttonCheck is true then
                    (*
                    tell application "SendMIDI" to activate with raw SysEx string by command-line of terminal;
                    or could another action option - like Click-command for UI button:
                    -- click the Compare_button to toggle its state
                    or MIDI Note_on message, which was add too at operated script below. see step of code after EOX (0xF7) at the end of the string:
                    *)
                    do shell script "/usr/local/bin/sendmidi" & " dev " & gPort & " raw hex F0 00 00 66 10 12 00 43 6f 6d 70 61 72 65 F7" -- MIDI message for true
                    do shell script "/usr/local/bin/sendmidi" & " dev " & gPort & " raw hex 90 2D 7F" -- Note-on message
                else
                    do shell script "/usr/local/bin/sendmidi" & " dev " & gPort & " raw hex F0 00 00 66 10 12 00 43 6f 6d 70 61 72 65 F7" -- MIDI message for false
                    do shell script "/usr/local/bin/sendmidi" & " dev " & gPort & " raw hex 90 2D 00" -- Note-off message
                end if
            end tell
        end tell
    end tell
end tell

end tell

0

There are 0 best solutions below