Created
January 22, 2018 02:03
-
-
Save latenitefilms/b16170b0171e109bd39f558e35fad90f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ax = require("hs._asm.axuielement") | |
app = hs.application("Final Cut Pro") | |
ae = ax.applicationElement(app) | |
o = ax.observer.new(app:pid()) | |
processChildren = function(child) | |
failureCount = 0 | |
failures = "" | |
for i, notification in pairs(ax.observer.notifications) do | |
local status, err = pcall(function() o:addWatcher(child, notification) end) | |
if not status then | |
failureCount = failureCount + 1 | |
if i == #ax.observer.notifications then | |
failures = failures .. notification | |
else | |
failures = failures .. notification .. ", " | |
end | |
end | |
end | |
if failureCount == 0 then | |
print(string.format("All notifications available for: %s", child)) | |
else | |
if failureCount == #ax.observer.notifications then | |
print(string.format("ERROR: All notifications unavailable for: %s", child)) | |
else | |
print(string.format("ERROR: Some notifications unavailable for: %s (%s)", child, failures)) | |
end | |
end | |
children = child:attributeValue("AXChildren") | |
if children and #children > 0 then | |
for _, v in pairs(children) do | |
processChildren(v) | |
end | |
end | |
end | |
rootChildren = ae:attributeValue("AXChildren") | |
if #rootChildren > 0 then | |
print(string.format("PROCESSING: %s", app)) | |
print("--------------------------------------") | |
for i, v in pairs(rootChildren) do | |
processChildren(v) | |
end | |
else | |
print("ERROR: There are no root children in application, so aborting.") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment