AppleScript App Using Safari Interface

In the mid 2 thousands I wanted to add an interface to a script I had written. I noted that Safari had pretty robust AppleScript capabilities, so I figured I could use HTML to build an interface. It took a lot of work and some workarounds, but it worked pretty well.

I recently wanted a simple way to scale images that I email or text, so I wouldn’t have to waste bandwidth with large images. So I created “Rob’s Photo Tool,” an AppleScript App that uses Safari for its interface. It’s a signed, notarized applet. Three screenshots are below that show (1.) an image being selected, (2.) the original image with scaling and (3.) the scaled image. A disk image with the app can be downloaded from my website at There is no included documentation, but its pretty simple and straight forward. Scaled images are saved to the location of the original file with a sequential number added to the file name. It should work with macOS versions greater than 10.10.

I found it challenging and given the time I spent on it, I should have just learned to program with Swift in Xcode. If anyone wants to try it, I’d be interested in hearing feedback.

1 Like

This is very interesting. With a few modifications this is something I could definitely use. I’d need to be able to customize units/dimenions/resulution, i’d prefer a drag’n’drop browser option and batch processing.

But what I find even more interesting is the entire concept of using Safari as an interface.

A browser is something I’ve wanted since FaceSpan up and died, and I think you have the potential here to build a system that script developers could use to build an interactive system.

–> Script Debugger 7.0.12 (7A112)
–> Mac OS 10.13.6 (17G14019)

Thanks for sharing. I have always waned to write an app to put up a picture then be able to change the name while I’m looking at the picture. You applescript would be a good starting point for me.

Have you considered making the tool open source?


Ed, it’s interesting that you mentioned FaceSpan. I used it back in the day and when I initially used Safari as a script / app interface I envisions something pretty much like FaceSpan, but built around HTML. Since that time, I think with the advances of CSS, JavaScript and jquery, the concept could do amazing things — especially with the media capabilities of Safari.

Robert, I’m not sure at this point what I will do. I have spent a lot of time writing the script and associated handlers. As you know, AppleScript is quirky and scripters frequently have to do a lot of work-arounds to get things to work. That’s one of the most frustrating things about AppleScript. It would be awesome if Apple were to add interface capabilities to Script Editor or even Xcode that only required knowledge of AppleScript & HTML. It seems to me that it would be great for scripters & Mac automation.

Quite impressive.

I recommend having a look at if you’d be willing to learn a new language for these kind of tools. As long as you run the programs only inside the Xojo app, you don’t have to purchase a license, even. It’s certainly easier to master than Swift, and I use it all the time for quick tools that don’t have to be pretty. Especially when it comes to processing files, doing graphics or even networking, Xojo is a good tool for the job.

For me, who learned many languages over the past 40 years, Xojo is my preferred tool for apps that run on desktop computers. Just like with the AppleScript-ObjC-Bridge, you can also teach Xojo to interface framework functions (with the “declare” statement).

I use AppleScript only where I actually need to script existing apps, or provide hooks into my own apps (like with iClip), or when I need to provide a tool for a customer and want it to be open source yet easy to run. For general apps, AppleScript is just too diffucult to handle, though. Despite great tools such as SD.

Sounds interesting. I’ll check it out. Thanks Thomas.

I’ve looked at xojo before and, like several other interface solutions, there is not an option to use AppleScript internally.

Since appleScript is preferred for inter application communication, that makes xojo useless for my purposes.

But an HTML interface builder that can call appleScript; AS-ObjC and JavaScript would be valuable.

Hey Ed, actually that’s not correct. You can easily use AppleScript in Xojo, either as text or as a compiled file.

Even so, I don’t think it is the best tool to get GUI forms for use with AppleScript.
I tried Xojo extensively for about 3 weeks, and it is a great tool for general app development, but not so much for general Mac automation.

For that, I have returned to using Keyboard Maestro. It has several built-in Prompts which are a lot better than plain AppleScript, including a Prompt With List action that has great incremental search and autocomplete much like macOS Spotlight search.
Then there is Custom HTML Prompt action which let’s you use HTML and JavaScript like on any web page. It’s very powerful.

Here is a brief demo of the Prompt with List KM Action.

Might be easy for you Michael, but it wasn’t for me. I gave it a try, and wasn’t at all happy. I also did a search on its web site for help using applescript with it and found nothing.

I’ll look at KM, but what’s needed is more than Prompts.

Ed, no problem.
If you can describe what else you need, I’ll try to respond.
KM has many, many features to facilitate Mac automation.
This includes the tight integration of AppleScripts and Shell Scripts to perform a wide variety of tasks.

Just so you know, I used AppleScript to build the input to the KM Prompt with List, and then the process the results.