4 ms·
As terrible as AppleScript is as a language, it's really nice that Apple even built a framework for apps to use to expose their functionality to external script
by bobbylarrybobby 5y ago
As terrible as AppleScript is as a language, it's really nice that Apple even built a framework for apps to use to expose their functionality to external scripts -- I'm not sure today's Apple would have gone to the trouble. And now that you can use JavaScript instead of AppleScript, with a more or less standard way of translating calls between the two, scripting+automating macOS is really painless.
I do wonder why the Shortcuts app seems to be reinventing the wheel. You'd think the functionality an app exposed to AppleScript would've been automatically made available in Shortcuts, with Shortcuts being more or less a block-based interface to the same scripting environment that AppleScript uses, but that doesn't seem to be the case. Kind of an odd choice to not build off their existing work there.
- crooked-v 5y ago> I do wonder why the Shortcuts app seems to be reinventing the wheel. Shortcuts is cross-platform, and so designed from the ground up to work sanely under the limitations of both macOS and iOS.
- mmerickel 5y agoI have plenty of shortcuts that work on iOS but don't work on macOS. It's fun when you use siri on the mac and it tells you it can't do something halfway through.
- fiddlerwoaroof 5y agoIt’s also relatively easy to use the Scripting Bridge from any language that can integrate with the objective-c runtime. I’ve written a bunch of Mac automation in Common Lisp
- alwillis 5y agoI had to automate transforming some Excel data for a friend recently and I did it using AppleScript. Turns out it’s not as bad as the prevailing HN narrative. It does require a change in mindset but once you get there, it’s actually quite nice, especially when using an app with a nicely designed dictionary. Like a lot of Apple’s technology from the 90’s, it was a technology before its time. It certainly was pretty important during Apple’s near death experience in the late 90’s due to the publishing workflows that could only be done (at that time) using AppleScript and Quark XPress, etc.
- fzumstein 5y agoHave a look at xlwings (I am the creator), it’s a Python wrapper around AppleScript that follows closely the original VBA object model, so won’t require a change in mindset.
- hhas02 5y agoHi Felix! Sorry I’m a jerk who never responds to PRs, although I know py3-appscript* is in its best hands with you so just keep rolling as you see fit. (*I am currently dragging nodeautomation back up to operational status so I can use it in new customer work, but that’s as much appscript-ing as my poor brain can cope with now.)
- fzumstein 5y agoHey has! I should have mentioned that xlwings is a wrapper around your excellent appscript package that does all the heavy lifting with AppleScript :) Thanks for reviving the project on GitHub :)
- hhas02 5y ago“I should have mentioned” Not at all. Results are what matters, not the technical gubbins under the hood. I’m happy appscript helps you to empower your users.
- jhbadger 5y agoIt's a "terrible language" in that it doesn't resemble most languages currently in use, but it resembles Hypercard's language Hypertalk a lot, so at the time it was created, this was a good idea. Hypercard/Hypertalk made GUI programming possible for non-technical people in a way that has not been possible since.
- tinus_hn 5y ago> I do wonder why the Shortcuts app seems to be reinventing the wheel. The Shortcuts app is a third party app bought by Apple.
- radicality 5y agoThe other day I wanted to do something seemingly simple with Shortcuts - set my screen and my 3 external displays brightness to 100%. I saw an action to set screen brightness, but figuring out how to apply it to a specific display is an exercise left to the reader ugh. Shortcuts so far seems like a very unpolished product. Do you know if something like this is easily doable in AppleScript (and whether it’s even worth it vs writing these kinds of things in swift with apple libraries)
- bobbylarrybobby 5y agohttps://apple.stackexchange.com/a/285907 https://apple.stackexchange.com/a/285907
- hhas02 5y ago“And now that you can use JavaScript instead of AppleScript” You really can’t. JXA is garbage, crippled, incompetent, and long since abandoned to pine for the fjords. Its only actual function is to impede any re-development of ES6 as a useful scripting platform within Apple, and probably hinders 3rd-party alternatives such as Scriptable and ScriptKit, because what 3rd-party dev wants to be pre-emptively Sherlocked by garbage like that? Apple abandoned AppleScript and AppleEvent-based automation after they gave the Mac Automation team multiple opportunities to make it successful—and they failed every one. Thus Apple fairly concludes it is a failed product on a legacy platform, ceases work on it because what’s the point on throwing more good money after bad, and looks elsewere for something new and more promising to try next. Hence Shortcuts, which started out as a 3rd-party iOS app, Workflow. As a technology it is at best mediocre; as a polished, well-presented, and properly-sold product it was already moving up on iOS with positive customer response. Instantly far more promising than the inept, lethargic, and generally couldn’t-sell-icecones-in-a-desert Mac Automation team, where the critical failure was never the technology itself but purely PEBKAC; but an organization the size of Apple doesn’t care about that distinction, only about its results. Thus, not too long after finally shitcanning the Mac Automation team in 2016, Apple bought up @WorkflowHQ outright, and have been positioning Shortcuts, née Workflow, for its true purpose: to provide their Siri UI with a reasonably granular, accessible, plugin backend so that Siri can actually make itself useful. … Lesson here for y’all: It does not matter one whit how good (or not) your technology is. (Apple themselves taught me that.) What matters is how good you are at selling product, i.e. putting bums on seats, and keeping them there. That’s why AppleEvent technology (which is in many ways far superior) now rots in history’s dustbin, while Apple gives the [Siri-backed and Siri-backing] Shortcuts its opportunity to prove itself a successful product and future of Apple Automation. Could a successful merging of the two produce a product 100× better? Sure. But if you’re asking that and not understanding why most likely won’t/can’t happen, you’re not understanding how successful big business works. My personal work (github.com/hhas/) testifies to hard lessons learned. (Though if you wish to have a crack, fill your boots. Perhaps you’ll do a better job n’me.)