Click check buttons via keyboard or script

applescriptautomatorfinal-cut-prokeyboard

I'm using Final Cut 7 under El Capitan, and I need to check the following buttons (in fact just the Audio Tracks, but both would be nice) using the keyboard, or maybe a scripted method.

example

I have already enabled keyboard shortcuts on the system preferences, so I can cancel (esc) or accept (return) this dialog using keyboard commands. However tab won't do nothing to circulate over the window components, and I am afraid this option was never implemented.

In fact the window title "Delete Tracks" keeps gray all the time, even with regular use via mouse, suggesting that it never has focus whatsoever.

Can I select those options via keyboard or script?

Also if you have another idea on how to delete just the empty tracks of the timeline using another automation method will be extremely appreciated. Just remember that because of license and workflow issues I can't upgrade to Final Cut X.

Best Answer

In Brazil we call this a "gambiarra", meaning an unconventional, unprofessional, improvised, sometimes lazy, workaround, temporary or definitive, for any given problem:

1st step - positioning the window to guarantee it will be always in the same spot:


on run
    tell application "Final Cut Pro"
            activate
    end tell
    tell application "System Events"
        set position of window "Delete Tracks" of process "Final Cut Pro" to {1150, 550}
    end tell
end run

2 - Use a Pyton shell script to click the exact point:


on run
    set x to 1200
    set y to 673

    do shell script " 
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import * 
def mouseEvent(type, posx, posy):
          theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
          CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
          mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
          mouseEvent(kCGEventLeftMouseDown, posx,posy);
          mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None); 
currentpos=CGEventGetLocation(ourEvent);             # Save current mouse position
mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y));      # Restore mouse position
END"

end run

And voila, problem solved:

enter image description here