Macs in Chemistry

Insanely Great Science


Applescript and Mojave


Well worth a read.

Executing AppleScript in a Mac app on macOS Mojave and dealing with AppleEvent sandboxing

Over a weekend recently I built a tiny Mac app (more on that later). What I was trying to achieve required executing AppleScript, like so many things on macOS. It seemed simple enough, but of course new app sandboxing restrictions in macOS Mojave got in the way.


An Applescript droplet to generate Augmented Reality files from JMol


Augmented reality is finding new applications in science, in particular the ability to enhance publications or lecture notes, and viewers can set up a free account with Augment to provide easy access.

I was asked recently if it might be possible to generate an AppleScript droplet that you could simply drop a chemical structure file onto to generate the desired files needed for the Augment, and this is an ideal use case for a droplet.

This script uses Jmol to generate the Wavefront .obj and .mtl files which can be used

You read more about the script and download it here.

Nick Greeves has tweeted an example of its use here and a demo page here.


Script Debugger 7 released


A new version of Script Debugger has been released.

Script Debugger is an integrated development environment focused entirely on AppleScript. This focus allows it to deliver a suite of tools that make AppleScript development amazingly productive. You can use it to write and edit code, analyze target applications, debug scripts, and more.



Scripting the Organic Chemistry Reference Resolver


Some time ago I published an AppleScript that allowed users to make use of the excellent Organic Chemistry Reference Resolver.

The Chemistry Reference Resolver serves to quickly direct you to a publisher's webpage that contains the article you are looking for: You type-in the reference The Resolver determines whether it is a journal citation, a DOI, a Sigma-Aldrich chemical search, or something more esoteric Based on the input, it then redirects you to the publisher's webpage – straight to the paper (or its nearest approximation) Many formats are supported including vaguely defined "lazy citations", such as "perkin1 2002 2733".

I was really delighted to hear recently that Brian Myers had customised the script to fit in better with his workflow. Simply copy the reference text to the clipboard and when you activate the script you can search for the reference immediately. Both versions of the script are available here.



CMD-D Masters of automation


Anyone who has touched upon scripting/automation on the Mac will no doubt have heard of Sal Soghoian so when I got this message recently I thought I'd better pass it on.

Sal here, with something pretty cool to share with you. We’ve started a new conference to bring together the Apple automation and scripting community!

The conference is called CMD-D (pronounced “Command-D”), and it will be held August 9th at the Santa Clara Convention Center. It’ll be a full day of exploring the current state of automation technology on both Apple platforms, sharing ideas and concepts, and showing what’s possible—all with the goal of inspiring and furthering development of your own automation projects. To assist in this exploration of all things Automation, I’ve invited some of my smartest friends to present sessions focused on their own areas of automation expertise, on macOS and iOS. And, for those new to automation, we’re also planning a Scripting Boot Camp on August 8th. I’m really excited about CMD-D. Finally, the Apple automation community has its own conference. If you use automation, create automation or develop software, this is your conference too.

Registration for CMD-D is open now!


Myriad Tables updated


I just noticed that the AppleScript Library Myriad Tables has been updated, Myriad Tables Lib is an AppleScript script library that gives AppleScript scripts the ability to show dialogs containing tables. It requires OS X 10.10 or later. This is just one of the great resources available from Mac OS X Automation

  • ASObjC Runner is a scriptable faceless background helper application. It has a dictionary with a range of commands focused on the areas where vanilla AppleScript comes up short. You use it like a scripting addition, except you address the commands to the application. It provides better string handling (e.g. change case, encoding URL’s, regular expression, formatting dates), list sorting and filtering, improved file handling and progress dialog boxes.
  • ASObjCExtras is a free framework that fills in some of the gaps in AppleScriptObjC support, as well as providing some useful extra facilities including methods for efficiently processing lists and strings.
  • Myriad Tables gives AppleScript scripts the ability to show dialogs containing tables.
  • CalendarLib_EC an AppleScript script library for manipulating calendar events without using
  • DialogToolkit an ASObjC-based script library for showing enhanced dialogs.
  • Myriad Helpers is a collection of Objective-C files that simplify some of the coding involved in AppleScriptObjC.

In addition there is also Everyday AppleScriptObjC the absolutely essential guide for anyone who wants to explore the full power of AppleScriptObjC.

For more information have a look at the AppleScript Resources Page.


Applescript & ASObjC ’Things to watch out for’ list


Brian Christmas has compiled an absolutely invaluable list of tips and samples of code for those using AppleScript or AppleScriptObjC. He has kindly allowed me to host a page containing all these tips

Applescript & ASObjC ’Things to watch out for’ list.

This list is a great resource for those just starting out but will also be invaluable for more experienced scripters.

If you would like to contribute probably the best way is to subscribe to one of the Apple mailing lists

There is a page of other AppleScript Resources here.


ASObjC Explorer has just been updated


ASObjC Explorer has just been updated to version 4.1.17, with fixes relating to Sierra. Choose 'Check for Updates...' to update.

Note also that ASObjC Explorer is no longer available for general sale. Barring bug-fixes, this is the last release -- there will be no further development. You can read more here:

Registered users are eligible for a 50% discount on Script Debugger 6 until mid-November as compensation, and should email Shane Stanley for details.

Development of Script Debugger 6

Its AppleScriptObjC code completion will be familiar to users of ASObjC Explorer, but goes further. And Script Debugger 6 ability to step through scripts and explore Cocoa results, to the point of being able to explore the contents of collection classes.



Scripting Openbabel


@MatToddChem recently tweeted

Chemdraw file containing lots of molecules --> separate png/jpg images of each molecule. Anyone got a script that automates that? #headache

Whilst it is possible to convert a ChemDraw file to an image the problem is you get a single png file containing all the structures. In order to get individual image files it is first necessary to separate the individual structures. The easiest way to this is to convert from cdx to SMILES format. We can then take each of the individual SMILES strings and generate an image using OpenBabel all controlled by an Applescript.


ASObjC Explorer, version 4.1


Just got this email.

A major update of ASObjC Explorer, version 4.1, is now available, just in time for the holiday season. This version incorporates a new and improved logging engine, incorporating extended AppleScript syntax styling and now resolving Cocoa objects -- no more will you have to deal with «class ocid» id «data optr000...» entries. ASObjC Explorer is the editor for Mavericks and Yosemite users wishing to write ASObjC code. You can read more here: You can also download it and try it out free for 30 days. To celebrate, you can use the coupon code NEWLOG to receive a $US10 discount between now and the end of January. Ho, ho.


ASObjC Explorer 4


New version for Yosemite and Mavericks users

ASObjC Explorer 4 is a script editor built to take full advantage of AppleScript’s ability to call Cocoa methods. With AppleScriptObjC-based libraries available in Mavericks and Yosemite, and now direct access to AppleScriptObjC code in Yosemite, ASObjC Explorer 4 can help you write and debug your code more quickly, more effortlessly, and more efficiently. It also makes a great external editor for those developing in Xcode.

ASObjC Explorer lets you write your code, write separate testing code, step through your code, log what happened, and even add scripting terminology — all in one document window. When you have finished, you can use your document as a script or library, or export to your favorite format, including Mavericks-compatible applets with embedded script libraries.

Full details are here.


Everyday AppleScriptObjC


Yosemite catches up to 'Everyday AppleScriptObjC'

Myriad Communications pleased to announce the availability of the second edition of 'Everyday AppleScriptObjC', updated for both Yosemite and Mavericks.

Yosemite confirms AppleScriptObjC's position as an important component of AppleScript, giving access to the Cocoa frameworks and their functionality wherever scripts are run. It is now truly an "everyday" option.

'Everyday AppleScriptObjC', Second Edition, provides an introduction to using the Cocoa frameworks from a scripter's point of view. It covers writing the code, in both Mavericks and Yosemite, as well as deployment issues.

The book has been updated to cover Yosemite, as well as to expand coverage in other areas. It is full of usable code snippets, which are also provided in file form in both Mavericks and Yosemite formats.

'Everyday AppleScriptObjC', Second Edition, is by Shane Stanley, author of 'AppleScript Explored', the guide to using AppleScriptObjC in Xcode. You can find out more here:<>. It is available now for $US14.95.


Applescript in the future


Applescript has had to take a bit of a back seat in recent years but there have been a couple of posts recently that will be of significant interest to all scripters.

Papers is a multi-award winning reference management application that hugely popular with scientists. I saw a very interesting entry on their blog.

The latest beta version of Papers for Mac adds support for scripting. This allows you to automate tasks or fetch and manipulate data in your Papers library by using AppleScript, or JavaScipt in Yosemite. Papers 3 features extensive AppleScript support that allows data to be fetched from a Papers library. You can also execute commands, like import and export. You can even create new data and set its most important properties. Some parts of the UI can be automated as well: the current selection can be changed, as well as the current view mode.

The importance of adding Applescript support to applications is nicely illustrated in an article by Brent Simmons, Making Your Mac App’s Data Scriptable.

Scripting isn’t a matter of automating button clicks; it’s about exposing the model layer to people who could use your app in their workflows.

There have been many concerns that the introduction of “sandboxing” will compromise the ability of applescripts to automate complex multi application workflows. There has been a recent article that shows the current best practices for controlling another app using AppleScript, Scripting from a Sandbox.

This comment sums things up nicely

While that’s usually a small minority of users (who use applescript), they’re power users — the kind of people who recommend apps to friends and family. They blog and tweet about apps, and people listen to them. They can be your app’s biggest evangelists.

And of course it is easy to share applescripts. I’ve added the links to the Applescript Resources page.


ASObjC Explorer has been updated


ASObjC Explorer for Mavericks

Changes from version 3.2.0 to 3.2.2

Code-completion enhancements. Code-completion has been enhanced for relevance. As part of this, Explorer supports new variable-naming conventions. Please read the section entitled 'Contextual Completion' in the Help file for more details.

Bug fix. Choosing 'Look Up in AppKiDo' from the contetual menu in the Library Pane erroneously entered the resulting script in the log. This no longer happens.

Sparkle update. A newer version of the Sparkle update framework is included. If you choose automatic updates, they should now happen automatically.

Updated scripts and user shortcuts. You can extract these from the application's bundle, or remove the existing ones and relaunch the application to have them instlled automatically.

Updated example scripts. These have been updated to reflect the new variable naming conventions


Version 3.2 of ASObjC Explorer for Mavericks


Version 3.2 of ASObjC Explorer for Mavericks, the script editor built to take full advantage of AppleScriptObjC, is now available.

The two main new features are Apple event logging, similar to tradition AppleScript editor logging, in addition to Explorer's own logging; and the ability to specify which thread scripts are run on, to facilitate debugging of scripts that use callbacks and times.

There are also a raft of scripting changes, several extra sample scripts, and improvements in several other areas.

You can read more here:


AppleScriptObjC Explored


As Apple provide ever improved means to build fully fledged applications using Applescript the documentation from Apple has become ever more outdated. Fortunately Shane Stanley has continued to update his absolutely essential book AppleScriptObjC Explored. I started building applications using AppleScript Studio, but with Mac OSX 10.6 we gained a new framework AppleScriptObjC. AppleScriptObjC was a new framework in OS X v10.6 that allowed Cocoa applications to be written in AppleScript. Using AppleScriptObjC AppleScript code can work with any Cocoa framework, and can function as a first-class citizen in the Cocoa world. It also brought scripters into contact with Xcode. This daunting transition may have left many of us floundering if it was not for this book.

The Fifth Edition of the definitive guide to building AppleScript-Cocoa applications in Xcode is now available, covering Mavericks and Xcode 5. Mavericks introduces new syntax specifically for AppleScriptObjC projects, and the book and accompanying projects have been fully revised to cover this, as well as the important changes in Xcode 5.

Whilst the book is excellent, what I’d like to highlight however are the sample projects, these are 20 fully-editable and annotated example projects that you can explore and modify.

This is the definitive guide and should be on every scripters bookcase.

There is more information on the Applescript Resources Page.


Numbers updated with Applescript support


Apple has released updates to their iWork productivity suite, perhaps most interestingly Numbers now regains applescript support. If you open the Applescript dictionary most of the classes and commands are now available again, still absent are “split into columns” and “split into rows”.


The mobile version of Numbers for iOS has also been updated.


Export as mol file script updated


I’ve added a minor update to the Export as mol file script.

One of the issues with the original script that the mol file contains in its first line the incorrect title of the file (it appears to be the name of the document template).

When you just launched your ChemDraw application, or created a new document, the title would be “Untitled **”, such as "Untitled ACS Document 1996-1". When you save it as Mol file, its header block will inherit the current document title "Untitled ACS Document 1996-2”.

Untitled ACS Document 1996-2

14 16  0  0  0  0  0  0  0  0999 V2000

It would be better to have the molfile title the same as the file name the user enters in the dialog box, one way to achieve this is to “edit” the file and then save again to the same file name. We can do this by adding a line to clean up the structure and then saving.

save first document in (molAttachment) as "MDL Molfile”
--This is to ensure the title of the mol file is set correctly
do menu item "Clean Up Structure" of menu "Structure"
save first document in (molAttachment) as "MDL Molfile"
close first document saving no

If you now look at the mol file in a text editor you can see the title is set more appropriately.

Mol file1.mol

14 16  0  0  0  0  0  0  0  0999 V2000

Export as mol file


A number of publishers are seeking to add extra value to publications by including access to chemical structure information to aid searching and indexing. More details are included in this comment from Elsevier.

Elsevier would like to enrich online articles by visualising and providing details of chemical structures you define as the main chemical compounds described in your article. For this purpose, mol files of the key compounds can be uploaded in EES. Please use your preferred drawing tool to export chemical structures as mol files and ensure that they are well defined and do not contain aromtic bonds, R-Groups or other variables. Submitted mol files will be available for downloading from your online article on ScienceDirect. Furthermore, Elsevier will generate InChI keys from the mol files and include them in the online article, which increase the online searchability of your article e.g. in Google. InChI keys will also be used to link the article to additional data in Reaxys.

Since you need to export each structure as an individual file this will become somewhat tedious, fortunately Brian Myers has written an applescript that greatly helps the process for ChemBioDraw users

Now updated.


ASObjC Explorer updated


I just saw this message from Shane Stanley

As some of you have probably found already, Xcode does not recognize AppleScript's new interleaved syntax when used for action handlers -- you cannot make connections to them from controls. The workaround is to keep using the underscore syntax for action handlers until the problem is resolved. That's not ideal if you use an external editor, though. FYI, I've just released a new version (3.0.7) of ASObjC Explorer for Mavericks to deal with this issue. There is a new preference setting in Preferences -> Other. When checked, every time you save a .applescript file, any single-argument handlers will be changed to use old-style underscore syntax. (The new syntax will appear in Xcode and in the saved file, while the new syntax will still appear in Explorer.)


Applescript and GUI in Mavericks

One of the big changes with Mavericks is the enhanced security and this has an impact on all developers even those who write a “simple” applescript to avoid a tedious or repetitive series of actions.

Developers have often relied upon AppleScript’s ability to control the user-interface, to provide an automation solution when no direct scripting support of an application or process was available. While this valued ability continues to be fully supported in Mavericks, the enhanced security focus of the new OS requires a few changes in how scripters access and apply the Accessibility frameworks.

There is a really comprehensive discussion of Accessibility Preferences and GUI Scripting over on Mac OS X Automation. Well worth a read.


ASObjC Explorer for Mavericks Released


Myriad Communications has released its successor to AppleScriptObjC Explorer, available immediately. The new editor takes advantage of the improvements to AppleScript in the latest release of OS X, which make access to Objective-C frameworks from AppleScript easier than ever.

"The changes to AppleScript in Mavericks have largely flown under everyone's radar, but script libraries open lots of doors for scripters," says the application's developer, Shane Stanley. "Bridging between AppleScript and Objective-C code has become much easier. This sets a new direction for expanding AppleScript's abilities."

ASObjC Explorer for Mavericks is designed to make developing AppleScriptObjC-based script libraries simple, with everything you need in one window. It features customised syntax formatting to take advantage of the new interleaved syntax; intelligent code-completion and shortcuts to take the tedium out of entering code; logging, stepping and breakpoints to aid in debugging; and a built-in simplified scripting-definition editor for adding English-like terminology.

It also makes an ideal external editor for AppleScriptObjC-based Xcode projects in Mavericks

ASObjC Explorer for Mavericks can be downloaded from <>, and can be used free for 30 days. The purchase price is $US49.95.

For further inquiries, contact Shane Stanley at <>.


Updated Applescript Resources


I’ve just updated the Applescript Resources page, in particular I’ve included updates to the great tools provided by Satimage-Software. These include Smile a programming and working environment that you can use in a variety of situations. You may want to perform a scientific work, to handle cgi requests, to automate an intensive file processing task, to produce computed graphics, to edit XML files, to work with Unicode texts, to make GUI of your scripts, and SmileLab the SmileLab license adds the data visualization features to Smile, the automation environment by Satimage-Software.


In SmileLab you can

  • extract data from files (default data formats supported: text, binary, FITS, XNF, ...),
  • perform data processing using commands provided with Smile or controlling external code
  • visualize your data in the most usual forms (curves, scatter plots, bar graphs, contour lines, color maps and vector fields in 2D, and 3D surfaces),
  • customize the interaction of the user with the plots (handling mouse clicks, contextual menus, keyboard events...) and create custom interfaces,
  • export your plot as a PDF file, as a bitmap picture (PNG, JPEG, TIFF, BMP, PSD) or as a QuickTime movie.


JSON Helper for Applescript

Recently there has been an increased use of JSON format for data exchange.

JSON, or JavaScript Object Notation, is a text-based open standard designed for easy human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages including including C, C++, C#, Java, JavaScript, Perl, Python.

JSON is built on two structures

  • A collection of name/value pairs. In various languages, this is realised as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realised as an array, vector, list, or sequence.

JSON can be used to provide the results of a calculation via a web service or it could be used to provide the results of a database search, indeed the popular database mongoDB uses JSON-style document storage. It can be regarded as less verbose alternative to XML.

I just noticed that there is now an Applescript parser for JSON,

Description. JSON Helper is an agent which allows you to do useful things with JSON (JavaScript Object Notation) directly from AppleScript. JSON Helper has no interface, and runs in the background waiting for AppleScripts to ask it to do something. JSON Helper is by far the easiest way to work with JSON in AppleScript. JSON Helper lets you convert JSON directly into AppleScript records, and convert AppleScript records and list into JSON. JSON Helper also makes it easy to parse the responses of many popular web services directly into AppleScript with convenience methods for fetching and parsing the responses from URLs.

I’ve added JSON Helper to the Applescript resources page.


Applescript to search un1Chem

Un1Chem is a new web resource provided by the EBI, it is a 'Unified Chemical Identifier' system, designed to assist in the rapid cross-referencing of chemical structures, and their identifiers, between databases. Currently the uniChem contains data from 19 different databases:-

Since ChemBioDraw can generate InChi Keys I thought it might be interesting to write an applescript that access this service. The InChIKey is a short, fixed-length character signature based on a hash code of the InChI string. By definition, hashing is a one-way conversion procedure and the original structure cannot be restored from the InChiKey allowing confidential searching.

Full details are here


Script Debugger Updated

If you are looking for an alternative to Script Editor then Script Debugger might be worth a look, and it has just been updated.

Script Debugger 5.0.6 is a free maintenance release addressing a series of issues that came to light following the release of Script Debugger 5.0. This maintenance release makes Script Debugger fully compatible with Mountain Lion (Mac OS X 10.8.2) and addresses a number of stability and performance issues.

There are more useful tools on the Applescript Resources page.


Platypus Updated

Platypus is a developer tool for the Mac OS X operating system. It creates native Mac OS X applications from interpreted scripts such as Applescript or shell scripts, or Perl, Ruby and Python programs. This is done by wrapping the script in an application bundle along with a native executable binary that runs the script.

The update includes

  • New "Prompt for file on launch" option
  • Redesigned Drop Settings sheet
  • Fixed issue where version would not appear in Get Info in Finder (missing CFBundleShortVersionString)
  • Generated apps have NSHumanReadableCopyright defined again
  • Extensive updates to documentation
  • "Provide as a Mac OS X Service" no longer enabled by default
  • Removed all support for file types. They are ancient crust now mostly ignored by Mac OS X and should no longer be used.
  • Improved uninstall script
  • Fixed issue where a generated icon file referenced in a Profile could be overwritten
  • Documentation files now open in default browser, not in default .html handling app
  • Fixed broken nib optimization. Platypus now correctly detects XCode 4 installs.

There are a number of other tools on the Applescript resources page.


Applescript Update

There have been a number of discussions about the impact of sandboxing on Appelscript, the latest update (10.8) helps to clarify the situation.

The full release notes are here.

Sandboxing and Running Scripts

Sandboxing your application may require changes to how it runs scripts. The usual method in the past has been NSAppleScript, but since scripts typically rely on sending Apple events and the default sandbox profile does not allow sending Apple events to any other application, this often does not work correctly when in a sandbox. Scripts run from your application will fall into one of three categories: • Self-targeted scripts. Your scripts only send events to your application and never to any other application. Continue to use NSAppleScript as before. • Built-in scripts. Your scripts are built as part of your application, and will not change after shipping. Continue to use NSAppleScript, but add entitlements for sending events to the target applications. • User scripts. Your scripts are supplied by the end user, and may use any other application. Use NSUserScriptTask. The scripts must be stored in a special location (use NSApplicationScriptsDirectory to determine where), and will run outside of your sandbox.

Sandboxing and Scriptability

Sandbox policy does not restrict receiving of Apple events, so in general, your application’s scriptability code will not be affected by sandboxing. Note: As mentioned under Compatibility above, sandboxed applications will not be able to access files referred to in commands using a string path. Any parameters or properties in your application that refer to files should be declared as type file, and not type text. Apple Event Manager will add sandbox extensions to events that have file-like parameters, but only if the parameter is of a recognized file-like type: typeAlias, typeFileURL, cFile, and so on. Without these extensions, the file will not be accessible from the target application’s sandbox, and the command will probably fail.

Your application’s scripting definition (sdef), however, should be updated to add access groups: groups of commands, classes, and so on that a sandboxed client can request to use with the new entitlement. For example, Mail defines a “compose” access group that allows creation and editing of an outgoing message, but nothing else. This is safer than the old entitlement, which allows access to the entire scripting interface. See sdef for details of the markup format.


Applescript and AppleScriptObjC

With WWDC about to open tomorrow I’ll be looking with interest to see if there any changes to Applescript and AppleScriptObjC.

I thought I’d also mention AppleScriptObjC Explored the book by Shane Stanley, this is the definitive guide to creating AppleScript Objective-C applications, and until Apple improve the documentation this is essential reading.

There is a list of Applescript resources here.


ChemDraw and Word compound numbering on Mac

A while back I got this question

”I’m about to hit the tedious part of writing my chemistry PhD thesis in Microsoft Word: having all mentioned compounds numbered in text and in the chemdraw imported files. My question: is there any automated option for this task or do I have to insert every number manually? In particular renumbering after adding a new compound in the middle of the text”

There are a couple of ways to do this in LaTex ( and ( but in my experience LaTex is not particularly popular among chemists. However help is at hand, I’ve just been sent details of a brilliant applescript that works with ChemBioDraw and Word.

The process is described in detail here ( so I won’t give anymore details just to add that one thing I’ve been using in recent Chemdraw scripts is

tell application id "com.cambridgesoft.ChemDraw"

It avoids the problems with application naming with different versions of Chem(Bio)Draw Std/Pro/Ultra.

There are many more applescripts here.


Chartsmith added to list of data analysis tools

I’ve just added Chartsmith to the list of data analysis tools.

Chartsmith is the premier charting and graphing application for Mac OS X. Built from the ground up on Mac OS X technologies, this application will make you and your data hum. Whether for scientific data visualization, for business presentation, or for graphics publishing, Chartsmith makes charting and graphing quick and easy.


Chartsmith supports a variety of chart types and can import from Excel or ascii text files. There is also Applescript support for automating workflows.

There is a comprehensive listing of data analysis tools for Mac OS X here.


AppleScriptObjC Explorer Updated to version 2.5

AppleScriptObjC Explorer is a script editor that takes advantage of AppleScript’s ability to call Cocoa methods in OS X 10.6 and later. AppleScriptObjC — AppleScript with the added ability to call MacOS X’s Objective-C-based frameworks using AppleScript syntax.

New in AppleScriptObjC Explorer 2.5.0

  • Script stepping. You can now step through scripts a statement at a time using new Step, Resume and Resume to Selection commands.
  • Updates to exported apps. Exported apps get individually named executables, plus correct name in their application menus.
  • Bug fixes. Fixes to compiling, saving as .applescript files, and logging time-stamps.

There more details on the Applescript Resources Page.


Cheminformatics on a Mac

I gave a talk at the Cambridge Cheminformatics meeting last week, I’ve put the slides here. It was more of a demonstration than a talk but the slides give an overview and links to the various tools.



A couple of people have asked for a pdf version of the slides for download.


Automating Exporting to Evernote

I had an interesting email from Geoff Hutchison who is using an iPad mini for taking notes using Notability the notes can be typed, handwritten using a stylus, or images. Notability does not export directly to Evernote an app that can capture and synchronise notes between multiple platforms including iPad and desktop. The other feature that makes Evernote interesting is it provides handwriting recognition, thus making the handwritten notes text searchable.

Geoff had a Automator service that imported the Notability notes that had been saved to Dropbox into EverNote, however he wanted a better way to name the notes created in Evernote. As it turned out the best way to do this was to use Applescript, you can read the full details here.


Script Debugger updated

Script Debugger 5.0.5 is a free maintenance release addressing a series of issues that came to light following the release of Script Debugger 5.0. This maintenance release improves compatibility with Mac OS X 10.8 by introducing support for bundle IDs in applets and droplets.

There are details of more Applescript tools in the Applescript Resources


Restarting the lmgrd license server

I use Moe for molecular modeling work, this uses a license.dat file in each installed MOE root directory that must be updated with the contents that you have been given by CCG (either by hard copy or e-mail). You can use any ASCII text editor (I used BBEdit) to edit the file. The FlexLM license manager lmgrd must be configured and run. Usually this runs quietly in the background and needs little intervention, however I've found that on some occasions the server quits (perhaps after updates) and needs to be restarted. However since it is something I don't need to do regularly I always spend a while working out the exact syntax. So I created this short Applescript to restart the server. Each time MOE gets updated you need to change the folder path, and I’ve updated the details to reflect this.


Using ChemBioDraw with MOE

As I mentioned in my recent review of MOE 2012 there is now support for using Marvin as an external 2D chemical drawing package, but what happens if you want to use another drawing package? Well that is where Applescript comes to the rescue, using Applescript support for shell scripts and one line of SVL (scientific vector language) we can use ChemBioDraw as the external editor. Full details of the script are here.


The Applescript section contains more tutorials, scripts and resources.


Applescript Pages

I did a little housekeeping on the Applescript pages, many thanks to those readers who reported bad links etc. it is much appreciated.


PublishPlot has been updated

PublishPlot has been updated and is now available from the Mac App store, it is a very handy tool for creating publication quality plots from any text based table of data.

PublishPlot is scriptable using either Applescript or Python.

New in version 1.1 is a tool bar to display x,y location when hovering over a plot, new fitting options and the ability to apply mathematical transforms to any two curves. There are also new export functions and bug fixes.

PublishPlot is included on the page of data analysis tools



EventScripts is a simple application for triggering AppleScripts or shell scripts whenever certain events occur.

The listing of events a quite comprehensive and includes such things as Volumes mounted or unmounted, computer wakes, screenshot taken application launched etc.

Now added to the Applescript Resources Page.


AppleScriptObjC Explored 4th edition

The fourth edition of AppleScriptObjC Explored, the indispensable reference to AppleScriptObjC, is now available, this guide written by Shane Stanley is absolutely essential for anyone wanting to access the Cocoa frameworks from Applescript.

Since the release of the third edition there have been significant changes to Xcode, and subsequently how applications are developed. Unfortunately, but inevitably, things have become a bit more complicated.

The new edition covers the changes that have been introduced in Xcode 4.4 and later, as well as in OS X 10.8, plus other new material and projects.

Changes include new projects covering drag-and-drop in tables and making an application scriptable, plus an expanded Xcode section with a subsection on mastering build settings. There are also several new chapters in the Reference section. Code for more than 25 projects is included.


The price is $29.95 and there are upgrade options for previous purchasers.

A really great book I’ve added to the AppleScript resources page.


AppleScript Library

I’ve just come across this fantastic AppleScript Library a collection of invaluable scripts and routines to make up for missing standard functionality. Currently there are libraries available for string manipulation, a files and folders library, iWork, a URL library and a number library.

A really great resource I’ve added to the AppleScript resources page.


Mac OSX Automation archive

The Mugginsoft application automation archive provides access to a browsable repository of automation documentation for a wide range of OS X applications. Documentation is provided for automation via AppleScript and the ScriptingBridge.

Added to the Applescript Resources page



I’ve just come across another site providing applescripts, Macscripz.

MacScripz are just really simple scripts. They basically function as tweaks to your system. A script can range from simply deleting a file in your OS to altering a previous setting. What most scripts on this site will do is change a setting set by Apple initially to change a core behavior on your system. For example, the tweak Cloak&Dagger forces Finder (on OS X 10.7 and up) to display files Apple hides from its users. Every script on is pre-screened, so don't ever worry about harming your system with any of our tweaks, we only upload quality content.

I’ve added it to the Applescript Resources Page.


Script Debugger 5.0.3 Released

Script Debugger 5.0.3 is a free maintenance release addressing a series of issues that came to light following the release of Script Debugger 5.0. This maintenance release makes Script Debugger fully compatible with Mountain Lion (Mac OS X 10.8) and addresses a number of stability and performance issues.


Script Debugger 5 updated

Script Debugger is an indispensable tool for anyone writing applescripts. If you are not familiar with this application it is worth watching the tutorials

Download Script Debugger 5.0.2

Bugs closed in the 5.0.2 release:

  • 17584 Resolved a crash that can occur when closing a paused document with leaked resources (e.g. unclosed files opened with the ‘open for access’ command).
  • 17570 The Recompile command is once again operational.
  • 17565 Corrected a problem where Script Debugger would not quit if the top window is an Event Log window.
  • 17489 Resolved a problem where Script Debugger would crash opening multiple document tabs on 10.6.4 systems.
  • 17548 Resolved a crash that happens when the event log window is opened, closed, reopened and then closed while the document remains open.
  • 17528 Script Debugger reopens scripts in their tabs rather than in separate windows following a crash.
  • 17521 Corrected a problem where text selections may not be drawn properly following a Replace All operation.
  • 17512 Resolved a problem where Script Debugger may report a parameter error (-50) when a script stops on 10.6.4 systems.
  • 17517 Improve the presentation when confirming document saving while closing a window with multiple dirty tabs.
  • 17487 Libraries added from the Application Support folder now default to ‘Relative To Application Support’.
  • 17480 Resolved a problem where Script Debugger crashes when launched on 10.6.4 systems.
  • 17505, 17543, 15974 Resolved a series of memory related bugs that may improve overall stability.
  • 17494 Improved performance when opening and compiling longer scripts.

There is a page of applescript resources here.


Chocolat Mac text editor

I’m a long time BBEdit user but I do keep an eye out for Mac text editors. Chocolat is a new text editor for the Mac that might be worth looking at, it supports split-window editing, code folding, and code completion. It can be used for a wide range of programming and scripting languages.


AppleScriptHTML updated

AppleScriptHTML coverts AppleScript source code to HTML representing styles and formatting.

AppleScriptHTML's features. * Clean HTML * Styles are applied by Cascading Style Sheets.  It is easy to customise styles after HTML generation.

  • Script Link
  • Can adding a link to open the AppleScript code in AppleScript Editor.  This function is useful for displaying sample codes

In version 2.4, the support of inline css is added.


Script Debugger has been updated

Script Debugger an advanced script editor has been updated.

Improved Inline Find & Replace Inspector Window and Result Drawer Unification
Script Debugger 5.0 combines Script Debugger 4.5′s various floating inspector panels and its Result drawer into three ‘tabs’ displayed along the right-hand side of each document.
New Bundle Editor Script Debugger 5.0 offers a new bundle editor where you can manipulate the resources contained within a bundled script or a script application.
Floating Mini Debugger This new window floats above all your applications.
New Value Explorer A central feature of Script Debugger is its value Explorers which let you inspect values. For Script Debugger 5.0, value Explorers have been completely re-implemented and simplified. The result is a much more powerful and efficient tool for examining values and exploring the objects and properties offered by the scriptable applications that you control in your scripts.
Element Filtering Script Debugger 5.0’s new Scope Bar lets you remove unwanted information from Explorers. For example, unselecting the ‘Empty Elements’ filter removes empty elements from the Explorer’s display.
Improved Handling of Large Element Collections Script Debugger 4.5 could slow down when displaying large element collections, such as the rows in a database. Script Debugger 5.0 avoids this problem by initially displaying only the first 30 rows. Data is then retrieved from the application for only those rows visible in the Explorer. Other rows are read only when they are scrolled into view. Press the new show more button to view additional rows.
New Apple Event Log Script Debugger 5.0 introduces an entirely new Apple Event Log which is integrated directly into the script window.Apple Events are now retained even when the log is not visible, allowing you to look at the event log without having to plan ahead. Additionally, you can change formats (source, raw, AEPrint) on the fly without having to re-run your script.
Explorable Local Variables When stepping through handlers, local variables containing object references can be explored in Script Debugger 5.0. Additionally, object references passed into handlers can show the target application.
Conditional Breakpoints Script Debugger 5.0 lets you assign conditions and actions to breakpoints.
Separate Running & Debugging Toolbars Script Debugger 5.0 offers two toolbar configurations: one for when debugging is disabled; and another for when debugging is enabled. You can customize the toolbar based on how you are using Script Debugger 5.0.
Script Debugger 5.0 improves its object model diagrams by showing element (one-to-many) relationships, and property (one-to-one) relationships.
Improved Spotlight Indexing
Fully 64-Bit Native


Adding drop shadows to chemical structures

As part of my day job I maintain Drug Discovery Resources a website intended to act as a resource for scientists undertaking drug discovery. One part of the site has a section on bioisosteres including many examples in which the chemical structures are shown with dropped shadows.

I use ChemBioDraw to draw the structures and then save as PNG files with a transparent background. The structures are then dropped onto webpages created using RapidWeaver, within RapidWeaver there is an option to add dropped shadows to images. I was recently asked whether there was any other way to create the same effect and Matt at macosxtips suggested using ImageMagick. This applescript droplet allows you to do so by simply dropping the file.


Copy file to Dropbox and email link

A while back I posted a script that copied a file to a users MobilMe Public folder and created an email link to that file. With the imminent demise of MobileMe a couple of people have asked me for a script that does the same but uses Dropbox.

This script shows how to copy a file to your Dropbox Public folder and then email a link to it.


Script to email Chemical Structures

A reader commented that they often emailed ChemBioDraw .cdx structures to colleagues who it turned out did not have a copy of ChemBioDraw to view them, whilst it is possible to convert the cdx file to other formats using OpenBabel they usually just ended up exchanging an image. They asked if there was a better solution and this is an ideal task for Applescript. This script assumes the structure you want to email is open in ChemBioDraw, it will create an email using Apple Mail containing the structure as a SMILES string, and embed the .cdx file together with an image in PNG format.



KosmicTask is an integrated scripting environment for Mac OS X. Whilst Mac OS X supports a number of scripting technologies either via it’s UNIX roots (Shell scripting , Perl etc.) or via Cocoa Framework Scripting using Apple’s scripting bridge (Applescript, Ruby, Python etc.) you can end up using a different script editor for each scripting language. KosmicTask allows you to script in a wide variety of languages from within a single editor. KosmicTask uses a plugin architecture that allows it to support a range of scripting languages, details of the languages supported by KosmicTask are shown below:-

KosmicTask also supports another very capable means of achieving automation - appscript. Appscript is supported by both Ruby and Python an alternative to the ScriptingBridge. 

It also allows sharing of scripts with other KosmicTask users via the local shared network.


I’ve also added it to the list of Applescript Resources.


Applescript to report installed and enabled extensions

When Apple released Safari version 5 one of the most important new features was the support for extensions. Extensions are a great way to add features to Safari to personalise web browsing, they enable the addition of features that you find useful. There is a listing of Extensions that might be useful for chemists and judging by the weblogs these are of significant interest. If you are working with them however it is a bit of a pain to check which are installed and which are enabled. This applescript is a very neat way of getting a report, it also serves as a demonstration of how to link to shell scripts, in particular using the unix command cat, a standard Unix utility that concatenates and lists files, to generate the report.


ASObjC Runner released.

ASObjC Runner is an invaluable scriptable faceless background helper application. It has a dictionary with a range of commands focused on the areas where vanilla AppleScript comes up short. It adds the ability to use the power of Cocoa frameworks within Applescript.

You use it like a scripting addition, except you address the commands to the application. It provides better string handling (e.g. change case, encoding URL’s, regular expression, formatting dates), list sorting and filtering, improved file handling and progress dialog boxes.

I’ve added to the page of Applescript Resources


Scripting the Chemical Identifier Resolver Updated

I was reminded that whilst scripting menu items was the traditional way of controlling ChemDraw the more recent releases allow control by scripting commands. This is a major advance since menus can change or be translated into other languages. I’ve thus updated the script.

I was asked if it would be possible to do the same thing for other drawing packages such as MarvinSketch?

The answer is yes but because MarvinSketch does not have applescript support we have to do it slightly differently. Rather than using scripting commands we script system events to evoke the “Paste” command.

Full details of the script are here


Scripting the Chemical Identifier Resolver

The name to structure feature in ChemBioDraw is very useful but is pretty much limited to systematic names and certainly does not support other chemical identifiers like CAS Numbers. There are a number of online services that do support these sort of functions but you end up having to cut and paste from different web sites. This is where the Chemical Identifier Resolver script comes into play.


AppleScriptObjC Explored

The 'AppleScriptObjC Explored' Addenda and Errata page has been updated to cover a change made in Xcode since version 4.0 came out. <>

AppleScriptObjC Explorer v2.2 is now available. It's a free update to existing users, and incorporates all the changes in the last beta version, plus built-in updating.

Myriad Helpers 1.0.2 is now available. It's a minor update, offering a new method fordTrig: to give access to trigonometry functions. <>


AppleScriptObjC Explored Third edition

Over the years I’ve migrated from Applescript Studio applications to AppleScriptObjC using Xcode 3 and last week I made the transition to Mac OSX 10.7.x and Xcode 4. With each transition there has been a very steep learning curve and to be honest the documentation provided by Apple has been woefully inadequate. Thankfully Shane Stanley has stepped up to the plate and provided a definitive guide for this people who want to build applications using applescript. AppleScriptObjC Explored is the definitive guide to building AppleScript Objective-C applications. It guides you step-by-step through the process of integrating the power of Cocoa into your AppleScript applets and applications, demonstrating each concept and technique in fully editable and annotated example projects.

The latest edition also includes a detailed navigation of Xcode 4, for those of us who had just learnt our way around Xcode 3 the changes made in the new version are significant and the section explaining where everything is and what they are for is invaluable, in fact it is probably worth reading this section before you start trying to write your first application.

Once you have a basic understanding of Xcode adding an interface to your script becomes largely point and click.

There is also a very useful section on trouble-shooting, and explanation of “gotchas” that will crop up occasionally.

The book comes with a collection of over 20 ready built Xcode tutorials/projects that demonstrate key implementations but that can also act as starting points for your own projects.

Whilst I keep a list of applescript resources, I suspect that AppleScriptObjC Explored is probably the most useful.


Scripting the Organic Chemistry Reference Resolver

The Organic Chemistry Reference Resolver is an invaluable web service that takes as input a text reference to a published article in a variety of formats and then finds and displays the corresponding publication.

The real beauty of a web service is that it can be accessed via a variety of means, including an applescript. This applescript uses as input either text that has been copied to the clipboard or the text the user has typed into a text box, it submits the request to the web service and displays the result in the web browser.


An alternative to the Delete Restore folder applescript

Matt over at MacOSX Tips has sent me an alternative script, in this rather than deleting the restore file it is simply enabled or disabled. This script demonstrates the implementation for Safari.


Delete Restore folders for selected applications

One of the new features in Lion is the ability of applications to resume activity at the point an application was quit. This means that when you reopen an application it will open and display all the documents you were editing in the state when you quit the application. This is obviously very useful but there are times when you may not want confidential documents automatically opened and displayed when you open an application.

This Applescript allows you to delete the restore folder for specified applications.

There are more applescripts here.


Update to AppleScriptObjC Explorer

Version 1.1.0 is now available. It includes several localizations, more frameworks, and the ability to check for and install updates. See for details.


Scripting ChemBioDraw

A script to convert .cdx to .png file format Read More...

AppleScriptObjC Explorer 2.1 released

A free update to AppleScriptObjC Explorer

AppleScriptObjC Explorer 2

AppleScript Explorer 2 has been "officially" released

AppleScriptObjC Explored

The third edition of 'AppleScriptObjC Explored' is out

ApplescriptObjC and XCode 4

AppleScriptObjC and XCode

AppleScriptObjC Explorer

A new version of AppleScriptObjC Explorer available

AppleScriptObjC Explorer

AppleScriptObjC Explorer is a script editor that takes advantage of AppleScript's ability to call Cocoa methods in OS X 10.6 and later. Read More...

AppleScriptObjC Explored Updated

AppleScriptObjC Explored has been Updated

Scripting the Script Editor

How to automate the Script Editor using Applescript

Applescript and curl

Using Applescript and curl

Myriad Helpers

More resources for applescript

AppleScritObjC Explored Updated

I’m looking at updating iBabel, to do so I need to migrate to AppleScriptObjC so I’ve been searching the Apple documentation for examples, tutorials etc. and I’ve found a pitiful amount of useful material. Read More...

AppleScriptObjC Explored

AppleScriptObjC Explored by Shane Stanley is the most advanced, thorough, and in-depth documentation for the creation of AppleScript Objective-C applications. Read More...

ChemInformatics scripts Updated

In the Applescript section there are a number of Applescripts that I use to generated calculated properties and descriptors. These make use of the cheminformatics tools provided by ChemAxon. Read More...

Applescript Resources

I’ve added Shane's ASObjC Utilities 0.9 to the Applescript Resources Page. Read More...

Rule of 7 Applescript

An applescript to generate and plot physiochemical properties It uses cxcalc from ChemAxon to generate the data and Aabel from Gigawiz to plot the results. Read More...

Applescript Resources

I’ve updated the Applescript resources page.

Programming iNMR

Programming iNMR

eMolecules Applescript

Applescript to search eMolecules

Applescript Resources

I’ve just updated the Applescript Resources Page.

Applescript and Automator

A webcast featuring Apple's Sal Sogohian. Sal is the product manager for Apple's automation products, including AppleScript and Automator. Read More...

Applescript to restart license manager lmgrd

Applescript to restart license manager lmgrd


Added Platypus to Applescript Resources

Applescript Resources

Updated Applescript Resources Page

Applescript Resources

A few new resources.

Applescript tutorial 11, Using GeekTool

Applescript tutorial 11, Using GeekTool.

Applescript Movie

A training movie describing how to use outlets and actions to connect the interfaces of AppleScript-Cocoa applications under Mac OS X 10.6. Read More...

Applescript Resources

I’ve updated the page of Applescript Resources

Applescript Chemistry Workflow

A chemistry workflow created using Applescript, Chemaxon tools and Aabel. Read More...

Applescript Resources

Applescript Resources for Mac OS X

Copy to mobileme

Applescript to copy a file to Mobileme and create an email message with the link. Read More...

AppleScript Language Guide Update

Well it took a while but the Applescript Language guide has been updated. Read More...

An Applescript Droplet that uses a command-line application

How to create a droplet that accesses a UNIX application. Read More...

Applescript Tutorials

Updated Applescript Tutorials

Applescript Lecture

I gave a lecture at the Scientific computing meeting at Cambridge University on using Applescript to build a User interface for Unix command-line applications. Read More...

Print Folder Contents

An applescript to print the names of all files and folders within a chosen folder (and sub-folders) using a couple of unix commands wrapped in an applescript. Read More...

Applescript Tutorial 9

Embedding chemical metadata into image files.

Applescript tutorial 8

Getting chemical structure embedded in images.

Comparing version number in applescript

Using the applescript command "considering numeric strings"

EndNote XI

EndNote has been updated to version XI

Print the clipboard

Print the clipboard directly.

Rendering chemical structures in the database

Chemical structure rendering by scripting ChemDraw.

Substructure searchable database

Creating a sub-structure searchable chemical database.

Applescript Tutorial 4 added

Latest Applescript tutorial has been added

Applescript Tutorial 3

This is the third Applescript tutorial written for MacResearch Read More...

New Applescript

Identifies potential duplicates of a file using Spotlight metadata Read More...

ChemDraw to Tiff Applescript

An applescript that converts ChemDraw structure files into TIFF format Read More...