Bill Cheesman of UIBrowser fame sent this in which may be of interest:
Mark and Shane,
I thought you would be interested to know that GUI Scripting can be used to script the Touch Bar in Script Debugger. I posted this script to the applescript-users mailing list this morning, with explanatory information. I will also be posting a demo Cocoa application showing how to use Quartz Event Taps to monitor usage of the Touch Bar.
This script works when run by Script Debugger:
-- Touch Bar GUI Scripting Demo -- 1.0.0 Bill Cheeseman 2017-04-21 -- Usage: Run this script in Script Editor or Script Debugger to see its Touch Bar information. property touchBarRole : "AXFunctionRowTopLevelElement" tell application "System Events" set frontApp to first application process whose frontmost is true try set touchBar to first UI element of frontApp whose role is touchBarRole on error errMsg number errNum display alert "No Touch Bar support" message "This application or the Mac running it does not support the Touch Bar, or accessibility has not been allowed for the script runner in the Security & Privacy pane of System Preferences. " & errMsg & space & errNum return end try set touchBarItems to value of attribute "AXChildren" of touchBar return properties of item 1 of touchBarItems end tell --> {minimum value:missing value, orientation:missing value, position:{80, 0}, class:pop up button, role description:"touchbar popover", accessibility description:"character picker", focused:false, title:"", size:{72, 30}, value:missing value, help:"Tap to choose special characters and emojis", enabled:true, maximum value:missing value, role:"AXPopUpButton", entire contents:{}, subrole:missing value, selected:missing value, name:missing value, description:"character picker"}
–
Bill Cheeseman - wjcheeseman@comcast.net