Logic pro X 中有一些 GUI 元素/按钮没有状态参数(value = nil 见附录)
所以我想创建一个 applescript 来检查该按钮的调色板,以便随后将 MIDI 消息分配给外部控制器。 虽然有一个想法 - 使用触发器的按钮颜色更改参数(arm-state 为蓝色,disarmstate 为灰色)...
有什么想法吗?
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()
*)
if compare_state 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