I have always begun my AppleScript code with use scripting additions. Recommend you do too. Here are some of the reasons you may wish to use scripting additions from querying AI:
Scripting additions, also known as OSAX (Open Scripting Architecture eXtensions), are used in AppleScript code to extend the language’s capabilities and provide functionality beyond what is natively available in AppleScript or through scriptable applications.
Reasons for using scripting additions include:
Expanding AppleScript’s Vocabulary:
Scripting additions introduce new commands and classes that are not part of AppleScript’s core features. For instance, the “Standard Additions” scripting addition provides commands for user interaction (like displaying dialogs), file system operations (like reading/writing files), date functions, and text/mathematical operations. Without these additions, AppleScript would be unable to perform many basic actions unless they were provided by a specific application.
Accessing System-Level Features:
Scripting additions can provide access to functionalities that are not exposed by scriptable applications, allowing AppleScript to interact more directly with the macOS operating system.
Adding Functionality from Lower-Level Languages:
Scripting additions are often written in lower-level languages like C, enabling them to offer performance benefits or access to system resources that are not easily managed directly within AppleScript.
Creating Custom Commands:
Developers can create their own scripting additions to add specialized commands tailored to specific needs, further extending AppleScript’s versatility.
Reducing Reliance on Applications:
By providing system-level or common functionalities, scripting additions can reduce the need for AppleScript to interact with specific applications for every basic task, making scripts more independent and potentially more robust.