Code Monkey home page Code Monkey logo

applescript-st's Introduction

Applescript-St

Communicate with Mac scriptable applications from within Pharo.

In a perfect world, this would mean accessing script objects as seemlessly as from within AppleScript (AS), but with the full power of Pharo's IDE. In reality, Apple Automation seems to be an absolute mess, making AS-like libraries in other languages problematic. Therefore, the easiest approach is to write scripts in AS (I know yuck) and at least be able to run then in Pharo. This is the minimum basic feature we provide. That said, providing something like rb-appscript, which allows AS-like Ruby code (e.g. all_names = Appscript.app("Finder").files.name.get) is a long-term dream.

Future

Given that Applescript seems to be dying, and maybe so is Mac Automation in general (see here and here), it’s unclear whether significant additional investment in Apple Events makes sense.

Hamish Sanderson has offered some brutal critiques on Apple’s failure to properly invest and deliver on Automation in general. While he seems to have finally given up on Mac Automation, his previous position seemed to be that: “the most reliable way for Objective-C applications to send Apple events is to call AppleScript handlers directly via the AppleScript-Objective-C bridge”. Prior to that, he had himself started - and seemingly abandoned - several attempts to overcome these deficits, including:

  • Appscript, which was ported to Python, Ruby, and Objective-C. The original repo was on sourceforge. While it’s said to be abandoned years ago, there are some commits from 2019. Also, Matt Neuberg put the code on GitHub, and there are at least a few forks that put some commits into updating it.
  • AppleEventBridge is "a modernized, reworked fork of the objc-appscript bridge.” However, “further development has been discontinued in favor of the SwiftAutomation framework… therefore its use is not recommended.”
  • SwiftAutomation framework "is an Apple event bridge that allows Apple's Swift language to control ‘AppleScriptable’ macOS applications directly", but “given current uncertainty regarding the future of Apple event-based automation the project is on hiatus until WWDC17”. While Hamish’s later comments suggest he’s given up, there are commits here too from 2019.
  • Entoli - "An experimental end-user language design, stealing ideas on semantic simplicity and syntactic friendliness from Logo and AppleScript respectively, while also [hopefully] avoiding their various pitfalls and errors.” While interesting, it’s not clear how this fits into the Automation picture.

History

applescript-st's People

Contributors

seandenigris avatar

Stargazers

 avatar

Watchers

 avatar  avatar

applescript-st's Issues

Wrap the World vs. Delegate

Editing

If we wrap AppleScript idioms, it is obviously more work initially, but thereafter we benefit from Smalltalk's IDE/tools. This approach might lead to a script like:

script
	tellScript := '	activate
  do script "{script}"'.
	Applescript tell: 'Terminal' to: tellScript

However, if we rely on AppleScript tools, inside the image, the script would be a string:

script
	^ 'tell application "Terminal"
	activate
	do script "{script}"
end tell'

One question: Are AppleScript tool features worth the loss of power?

Mac Script Editor

TLDR: It sucks

Features:

  • Syntax highlighting
  • Code completion - claimed but doesn't seem to work
  • Dictionary access
  • Compile/Run buttons

It's actually a poor experience.

Script Debugger (from Late Night Software)

This one is very promising!

Case Study: Pharo-Shell

Here, we need to open a Terminal window and paste in the command (possibly not running it). The concept is that maybe we need to first su or run as sudo and can't do it from within Pharo, so we'll throw the command out to Terminal and let the user proceed there.

There are two main parts:

  1. The script itself
  2. Running the script

We want to use AppleScript to accomplish this. The thing is that we already have all this implemented in SimpleApplescript and don't want to duplicate (possibly buggily) here. However, PharoShell is also a low level library on Which AppleScript itself depends, so we don't want to create a circular dependency because currently AppleScript loads OSProcess which seems a bit crazy for Pharo-Shell, which is (supposed to be?) a lightweight replacement for OSProcess. I guess other strategies might be to reconsider the dependency on OSProcess?

So... the immediate fix will be: separate script and running. Although after trying this, I'm thoroughly disgusted with trying to recode the entire concept of AppleScript and might look back into how the AS plugin worked to see if we can send real apple events.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.