MacOS – Is it possible to modify the behavior of Finder UI elements with AppleScript

applescriptfindermacos

I wrote an AppleScript that scans my entire iTunes library and tags those files with their Genre (so I can easily access them in Finder by just clicking the right tag).

The next step on my list would be to "modify" the Finder behavior. What I exactly mean is that I want to be able to double click a tag in the Finder window and then all music files that are tagged should be added to a playlist and that playlist should be started.

I have no idea if that is even possible. But if it is, I would really like to get some ideas where I have to start to achieve my goal.

I already googled a bit but couldn't find anything that goes into that direction.
One of my thoughts would be a kind of 'broadcast feature' where AppleScripts may register for specific UI elements and if the user triggers something the script gets informed.

Hopefully someone has a clue and might be able to help me out!

Best Answer

This is currently not possible with AppleScript. AppleScript can't bind itself to the UI in that way.