{"id":13575085,"url":"https://github.com/fractaledmind/applescript_helpers","last_synced_at":"2025-04-19T15:56:14.224Z","repository":{"id":14438696,"uuid":"17150124","full_name":"fractaledmind/applescript_helpers","owner":"fractaledmind","description":"Handlers for AS user-interaction function","archived":false,"fork":false,"pushed_at":"2014-06-12T16:58:26.000Z","size":440,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T09:42:02.770Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"AppleScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fractaledmind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-24T20:45:29.000Z","updated_at":"2024-03-15T00:09:19.000Z","dependencies_parsed_at":"2022-09-08T08:11:32.815Z","dependency_job_id":null,"html_url":"https://github.com/fractaledmind/applescript_helpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fapplescript_helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fapplescript_helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fapplescript_helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fapplescript_helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fractaledmind","download_url":"https://codeload.github.com/fractaledmind/applescript_helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249731331,"owners_count":21317342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:00:58.143Z","updated_at":"2025-04-19T15:56:14.208Z","avatar_url":"https://github.com/fractaledmind.png","language":"AppleScript","funding_links":[],"categories":["AppleScript"],"sub_categories":[],"readme":"# AppleScript Helper Functions\n\nThese are two sets of Applescript functions that make common tasks easier, cleaner, and simpler. One set is aimed specifically at building [Alfred workflows](http://www.alfredforum.com/forum/3-share-your-workflows/), while the other is more generally usefully for generating Applescript's own user-interaction dialogs.\n\n\n## User-Interaction\n\nThis is an AppleScript library for the primary user-interaction functions available to AppleScript. This library provides a terse means by which to access these user-interaction functions:\n\n* display dialog\n* choose from list\n* choose file\n* choose folder\n* display notification\n* display alert\n* say\n\nIn each case, this library provides a consistent syntax for utilizing the full range of optional parameters for each function, while also ensuring that each user-interaction is always presented front-and-center and will fail silently. \n\nAt its heart, this library contains these functions (which map to those above):\n\n* display_dialog(record)\n* choose_from_list(record)\n* choose_file(record)\n* choose_folder(record)\n* display_notification(record)\n* display_alert(record)\n* say_text(record)\n\n## Features/Advantages\nEach function builds upon this general user-interaction framework:\n\u003cpre\u003e\u003ccode\u003e\ntry\n\ttell application (path to frontmost application as text)\n\t\tdisplay dialog \"Hello world!\"\n\tend tell\non error errText number errNum\n\tif not (errNum is equal to -128) then\n\t\ttell application id \"sevs\"\n\t\t\tdisplay dialog \"Hello world!\"\n\t\tend tell\n\tend if\nend try\n\u003c/code\u003e\u003c/pre\u003e\n\nWhile verbose, this skeleton will ensure that user-interactions are always front-and-center and fail gracefully. This library allows you to present all user-interactions this way without the hassle of the skeleton. \n\nEach function also requires an Applescript Record as its argument. Necessarily, the possible keys for this record are fixed by the library, but are consistent and will be explained in the documentation. The advantage of this approach is simply concision and consistency. The library functions take care of the syntax\n\n## Alfred Functions\n\nThis Applescript grants quick access to certain common functions in building and running Alfred workflows. Many of the functions are from [qlassiqa's qWorkflow library](https://github.com/qlassiqa/qWorkflow). Functions include:\n\n* get_path() = returns POSIX path to `cwd`\n* get_bundle() = returns workflow's `bundleid`\n* init_paths() = ensures workflow's `storage` and `cache` paths exist\n* get_cache() = returns POSIX path to workflow's `cache` directory\n* get_storage() = returns POSIX path to workflow's `storage` directory\n* get_home() = returns POSIX path to user's `home` directory\n* mdfind(query) = returns list of results from `mdfind`\n\nIn addition to this functions, most of which are derived from [qlassiqa's qWorkflow library](https://github.com/qlassiqa/qWorkflow), I have also included a function to read simple JSON (i.e. no nesting). This proves helpful for `settings` or `preferences` files created in workflows. Simply pass the JSON string to the `read_json(json)` function. It returns an Applescript record, the keys of which will all be prepending with `_`. For example, the JSON:\n```\n{\n    \"type\": \"user\",\n    \"user_id\": \"12345678\",\n    \"api_key\": \"xxxxxxxxxxxxxxxxxxxxx\"\n}\n``` \nwill return the Applescript record: `{_type:\"user\", _user_id:\"12345678\", _api_key:\"rf8L5AZdrVlK9NMTXDVuotok\"}`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Fapplescript_helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffractaledmind%2Fapplescript_helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Fapplescript_helpers/lists"}