One of the most popular downloads on the site is the "Print Clipboard" script. This AppleScript prints any text copied to the clipboard without the need to paste the text into a text editor or word processor prior to printing. I was recently asked if it might be possible to have an option to save the text to a pdf file rather than printing. So I've added the option to print to pdf.
Copy any text to the clipboard and run the script. The first dialog shows the content of the clipboard
Click OK, and then the second dialog gives the option to Print directly (default option) or you can save as a pdf on your desktop. You can of course choose your own file name.
You can download the AppleScript here.
If you want quick access to scripts I recommend selecting "Show Script menu in menu bar" in the Script Editor preferences.
Anyone who is interested in AppleScript or automator workflows on a Mac will have heard of Sal Soghoian, Sal joined Apple Inc. in January 1997 to serve as the Product Manager of Automation Technologies. These technologies include AppleScript, Services, the Terminal, Apple Configurator and Automator, among others. Since he left Apple he has continued to develop automation and describe them on his website User Automation.
This website is dedicated to informing individuals about the tools at their disposal that can be used by them to control the devices they engage with and rely upon every day. I hope you find this information useful. — Sal Soghoian
In a recent video Sal describes how to use an accessibility feature hidden deep within macOS and turn an iPad into a completely customizable control panel for a Mac.
Full details are here https://userautomation.com/article/blog0003.html.
It requires a Luna Display dongle since Apple’s Sidecar technology won’t work because it doesn’t allow touch input on the iPad when it’s acting as a Mac screen.
macosxautomation released a couple of upgrades. FileManagerLib 2.3.2 now has commands for dealing with date properties, while RegexAndStuffLib 1.0.6 accepts lists of strings for its regex change and regex batch commands.
In addition an update to Script-Debugger has been released, This release also introduces a series of changes to improve compatibility with macOS Catalina (10.15).
I recently wrote a script in response to a tweet
A reader wrote in to ask if it might be possible to modify the script to use the identifier in the file containing the SMILES string as shown below.
Ic1ccccc1 ID_1 CC=O ID_2 CC(O)=O ID_3 CC(OC(C)=O)=O ID_4 CC(C)=O ID_5 CC#N ID_6 CC(c1ccccc1)=O ID_7 CC(Br)=O ID_8 CC(Cl)=O ID_9
So I've modified the script to allow this, the full details are here including a link to download the script.
Well worth a read.
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.
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.
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.
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.
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! http://www.cmddconf.com.
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 Calendar.app.
- 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.
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
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 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.
@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.
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: http://www.macosxautomation.com/applescript/apps/explorer.html. 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.
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.
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:<http://www.macosxautomation.com/applescript/apps/everyday_book.html>. It is available now for $US14.95.
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.
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 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, 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:
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.
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.
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 ChemDraw12201318592D 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 ChemDraw12201319082D 14 16 0 0 0 0 0 0 0 0999 V2000
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
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.)
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.
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 <http://www.macosxautomation.com/applescript/apps/explorer.html>, and can be used free for 30 days. The purchase price is $US49.95.
For further inquiries, contact Shane Stanley at <firstname.lastname@example.org>.
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.