September 2012
1 post
Anonymous asked: Any idea how to get the bootcamp script to work in 10.8?
April 2012
3 posts
3 tags
Encrypt and Decrypt text through AppleScript
If you want an easy way to encrypt and decrypt text using a passphrase, this may be something for you. I’ve written a Java command line tool using Jasypt (an open source library for encryption) that you can call from your AppleScripts.
Download the Jar file.
Call it from your AppleScript using a “do shell script” command like this:
-- Encrypt text set textToEncrypt to quoted...
Create a dynamic "Today In History" wallpaper with...
Okay, this one is a little more advanced than the other scripts I’ve posted and it requires the command line tool ImageMagick (free, open source) to be installed on your system.
Here’s what it does:
Use curl to download the html source of this webpage.
Use AppleScript’s text item delimiters to extract the text entries.
Use the “strip” handler to remove html tags...
2 tags
How to Embed Source Code In Tumblr Blog Posts...
I just found this little gem for those of you who want to put source code in your blog posts. I will surely use it from now on.
5pmposts:
Being a developer, we often write code related blog posts and often struggle with its’ formatting. Here’s what I need:
Render code with good formatting
Allow copy and paste
Allow me to manage changes to the code
It’s been around for a while now, but Gist...
March 2012
3 posts
EjectAll! →
AppleScript brilliance in one line!
wozwas:
This is literally, the simplest (and perhaps my favorite) script, I’ve ever written. Ready for it, cause here it is:
tell application “Finder” to eject (every disk whose ejectable is true)
Yup, that’s it. It just ejects any drives or images currently mounted on my Mac. Brilliant stuff that I take full credit for, even though, as always, it’s just...
Programming is the art of figuring out what you want so precisely that even a...
– Anon (via randomguy3, ajcates)
6 tags
Upload images to imgur.com
It’s been a long time since my last post. Since I started school again, I’ve been focusing mainly on Java and iPhone development. But… I’m back with a new script that I think will be useful to a lot of people: Right click an image file and select “Upload to imgur”. Once the image(s) have been uploaded, your default browser will open a tab for each image.
If...
August 2011
8 posts
3 tags
Decimal to Binary Converter
This week I’ve started my computer science studies. Some of the exercises in one of the work books involved converting between decimal and binary numbers. Converting from binary to decimal is easy to do in the head, which I’ll show you, but I need pencil and paper to go the other way. I asked a teacher if he knew any tricks, and he challenged me to come up with an algorithm for it.
So...
4 tags
Using AppleScript to return a random quote
Here’s an easy way to put a random quote anywhere you like.
This script looks through a text file containing hundreds of quotes, then it selects a random quote and returns it. Here’s a link to the text file I use. I grabbed it from this site where you can find several other collections of quotes in plain text files. However, if you choose to use a different quote collection, you will...
4 tags
AppleScript code formatting fixed.
Since I started writing this blog I’ve been trying to find a way to have the actual AppleScript code displayed as plain text so that users could just copy-paste the script into their editor.
Well, I finally figured out how to do it and I’ve updated all my previous posts. In case you’re interested, here’s how I did it:
Click the “html” button in the post...
4 tags
AppleScript Voice Control
I haven’t used Apple’s Speech Recognition much in the past, except play around with it for few minutes. But combining it with AppleScript might actually be a way to make it useful to me.
SpeechRecognitionServer (a scripting addition installed on all Macs) has only three commands which I’ll explain briefly. They have to be called from a SpeechRecognitionServer tell block. When...
1 tag
Join me on Google+
For those interested here is my Google+ profile.
I still have some invites left if you need one.
4 tags
Translate words or phrases between languages...
This handler translates a string variable from one language to another. I couldn’t find anything useful on the web so I had to write my own. It’s by far the most comprehensive handler I’ve written so there may be a few bugs. If you find one, please leave a comment.
Instructions on how to use the handler are in the comment sections of the script. If you can’t get it to...
3 tags
A cry for (design) help!
I haven’t figured out all the possibilities with Tumblr yet, and honestly I don’t have the patience to check out all the different theming options. Maybe you can help me?
I’m looking for a design/theme that allows me to insert AppleScript code so it’s easier for the viewer to read and copy it to the Script Editor. With this theme I can’t write comments in my scripts...
8 tags
Create an Automator Service to download any...
Well, maybe not “any” movie but I haven’t come across any that weren’t supported yet. If you find a site that doesn’t work please leave a comment.
Here’s how you do it.
Open Automator and create a new Service.
Set input to URLs in any application.
Add a “Run AppleScript” brick.
Copy the following script.
Save.
From now on you can...
June 2011
6 posts
4 tags
Use AppleScript to create a log file of your data.
In this post I’ll show you how to create a text file log formatted as tab separated values. The data I’ll store in the log will be the temperature in Copenhagen Denmark, but obviously it could be anything at all.
First we need to store the data in a variable. I’ll get the temperature by using the UNIX curl command on a web page containing the data I need (temperature in...
4 tags
Using GeekTool to run AppleScripts on the desktop
I’ve been using the free preference pane GeekTool for a while now, and for a number of different reasons. First it’s obviously any geek’s dream to customize the desktop with homemade widgets, and second it’s a great way to schedule scripts that I want to run periodically.
This is what my desktop currently looks like.
Here’s a link to the full resolution picture.
...
3 tags
AppleScript handler returns ordinal suffix
I didn’t write this one myself but I use it quite often so I thought I would share it. This handler takes a number (integer) and returns the correct ordinal suffix (st, nd, rd, th) for that number. 1 returns st, 2 returns nd and so on.
The script is after the break.
on ordinalSuffix(anInteger) try set anInteger to anInteger as integer on error errorText return errorText end try ...
4 tags
Use AppleScript for easy rebooting to Bootcamp
This is a script I use every time I need to boot my iMac to Windows on Bootcamp. I have a keyboard command assigned to it so I can reboot into windows with just one keystroke.
To customize the script for your system, rename “Windows on Bootcamp” (you can see the name in System Preferences/Startup Disk).
Lion users have to make one small change to make the script work. Replace click...
3 tags
An AppleScript handler to calculate time units...
This is the first useful handler I’ve written. Insert it in an AppleScript and call it using this syntax:
getTimeSince(dateVariable, stringVariable)
The dateVariable should obviously contain a date. The stringVariable defines which time unit you want the handler to return. The following can be used:
“y” returns years “m” returns months (a month means years/12,...
5 tags
Create new ToDo in iCal based on text in email.
This is my first Mail rule script.
I have a rule in Mail set up to trigger when an incoming message has the subject “2do”. It runs the following AppleScript and moves the messages away from my inbox.
The script reads the first three paragraphs (text lines ending with return) of the email and creates a new ToDo in iCal’s “Home” calendar based on this text.
Line 1...