r/applescript • u/roycetech • Jul 10 '23
Introduction to AppleScript Core Framework Blog Post
I am sharing my blog post on Medium about the framework I used to help me simplify writing AppleScript codes that I use to streamline my everyday workflow and tweak my favorite apps.
I'd love to hear your thoughts, feedback, and ideas, so please feel free to leave a comment and share your experiences. Thank you!
https://medium.com/@royce.remulla/introducing-the-applescript-core-framework-eee7825e7853
7
Upvotes
2
u/Identd Jul 10 '23
I was also thinking of doing something like this. Feel free to DM me, I’d love to help on this. See my work here https://github.com/identd113/HDHR_VCR-AS
2
u/copperdomebodha Jul 10 '23 edited Jul 11 '23
I'm not sure if you're aware of the various libraries available that have already been produced. https://github.com/AppleScript-Library-Project/library-listing has a fairly exhaustive listing of the most significant libraries. There is also a code-exchange section on MacScripter that contains numerous resources that you might be interested in.
I have my own AppleScript library that I reference in most of my scripts, as I'm sure many others do, and it grows as I add additional functionality.
One thing that I don't believe is widely known regarding the loading and use of AppleScript libraries that I take advantage of is that you can load a library into a script as the script's parent.
This makes the handlers in the library available at the top level of your script directly. This removes the need to address the library when calling the handlers. This also makes all other top-level variables and properties available directly to your script.
This lets me code more succinctly, nest handler calls easily and the code is more readable and beautiful. Here is an example:
Libraries can also load other libraries. My 'Adobe_Photoshop_2023_Library_v2.scptd' loads 'Uber.scptd' as its parent. Any script loading the 'Adobe_Photoshop_2023_Library_v2.scptd' library has access to the Uber library through this chain of inheritance.
EDIT: I explored your code and it's very well done. Not very applescripty in many ways, but I think that's your point. Nicely done.