Tag Archives: applescript

Preview, sips, and more: OS X image processing tools

On a recent trip, I found I had failed to add copies of my auto-resizing drop tools to my travel MacBook Air. My droplets allow me to convert images to TUAW-standard sizes, namely 225 pixels for small images and 456 pixels for banner images. (See? Information you never thought you'd need to know.)

What a lot of people don't realize is that OS X offers solutions for these kinds of basic image tasks.

First and foremost is Preview. This app is simply terrific. Yes, I know, Apple took some really helpful utilities like Link Annotation out of the app on its road to Mountain Lion. (Time? Feature trimming? It's hard to say.) Even so, Preview is the best app on your computer that nobody uses enough.

Preview offers a surprising tool suite that combines a little bit of Photoshop and a little bit of Acrobat into one app. In addition to annotating PDFs, you can rotate and crop images using Preview's Tools menu. You have access to lasso selection, color correction, and image fitting, among many other features.

At one point Steve Sande and I threw around the idea of writing an entire book on Preview (there's plenty of interesting material in there!) but ended up deciding against it. Unfortunately, demand leads sales and too few people know how powerful Preview can be.

To resize an image, choose Tools > Adjust Size or click the resizing icon you see at the top-right of this post's main image. The icon looks like an arrowed line in a square box. An Image Dimensions panel slides into view, as you see here.

Preview and sips iOS image processing tools

Select the new width you want to use, making sure the small icon next to the two text fields remains in the locked position. This ensures that the height and width scale proportionately, so the resulting image is sized just right.

Preview isn't the only resizing solution on your Mac, however. The "sips" command line tool offers another take on image processing, one that's especially convenient for scripting and batch processing.

For example, if you want to resize an image to fit a given width, you can ask it to resample to the pixel count you supply. Here's how you might do that.

% sips --resampleWidth 225 input.png --o output.png

You can also perform many of the same tasks as preview. For example, you might rotate an image clockwise by 90 degrees:

% sips -r 90 input.png -o output.png

or convert a file from PNG to JPG format:

% sips -s format jpeg input.png -o output.jpg

OS X also supports related based on "folder actions". These refer to AppleScripts that you attach to folders, so when you drop items into the folders, they run those scripts. It's easy to take a peek at some of the system-supplied actions.

Create a new folder on your desktop. Control-click or Right-click it and choose Services > Folder Action Setup from the contextual pop-up menu. Select a pre-built script like "Duplicate as JPEG" or "Rotate Left" and click Attach. Finish by checking "Enable Folder Actions". Your new folder applies the attached script to any file you drop into it.

Preview and sips iOS image processing tools

If you're an intrepid system-modding type, you can expand these script choices by adding items to ~/Library/Scripts/Folder Action Scripts. (The system supplied versions all appear in /Library/Scripts/Folder Action Scripts).

Scripts are built around a standalone Image Events application, found in /System/Library/CoreServices. This app provides a "faceless background application" that wraps sips for AppleScript scripting. Apple has documented Image Events as part of its developer library, and its docs point to this external website that details how you integrate scripting with image manipulation requests.

I'll leave the rest as an exercise for the reader, but a bit of Googling will turn up already-built image solutions ready for testing.

Here at TUAW, we regularly use these for image resizing -- and they're exactly the bits I forgot to pack on my trip.

So did I get my work done while gone? You bet I did. And a big part of that reason is how sips and Preview enable you to step up to image challenges without any third party software needed.

Got some OS X image processing tips? Share them in the comments.

Preview, sips, and more: OS X image processing tools originally appeared on TUAW - The Unofficial Apple Weblog on Thu, 16 May 2013 14:00:00 EST. Please see our terms for use of feeds.

Source

Adding copy-to-clipboard rollovers in Contacts app via AppleScript

Adding Copy to Clipboard Rollovers in Contacts App via AppleScriptApple's Contacts app includes a lot of great shortcuts for initiating different forms of communication. Just click an email address, phone number or URL field label to display a list of available options. You can send an email, show a phone number in large type or start a FaceTime call, for example. Curiously, one shortcut that's absent from most of these popups is one for copying the email address, phone number, URL, etc. to the clipboard. Mailing addresses are one exception, as they provide an option to copy a mailing label. But, other fields don't include this option. Sure, you could just select a phone number, email address, URL, etc., and press Command+C to copy it. But, what fun is that? It sure would be nice if there were just more handy copy-to-clipboard shortcuts instead. With the help of AppleScript, you can add your own. Here's how...

Writing the Script

The following steps demonstrate how to add a Copy to Clipboard shortcut to phone number fields in the Contacts app. If you have any trouble following along, you can download the complete script here, along with ones for email address and URL fields too.

1. Launch AppleScript Editor (in /Applications/Utilities)

2. Create a new script document and enter the following code:

Note: If you want to create a version of this script for email address or URL fields, just change the action property handler to return the appropriate field type, i.e.,

on action property
return "email"
end action property

or...

on action property
return "url"
end action property

Installing and Using the Script

In order for the script you created to appear in the Contacts app, it needs to be saved in the proper place.

1. Quit Contacts if it's running.

2. Save the script you created as Contacts > Copy Phone to Clipboard.scpt, in script format, into the ~/Library/Address Book Plug-Ins folder in your Home directory. If this folder doesn't already exist, go ahead and create it.

Adding Copy to Clipboard Rollovers in Contacts App via AppleScript

Now, just relaunch the Contacts app. When you click on a phone number field label, you should see a new option for copying the phone number to the clipboard. Now, repeat the steps above for email addresses and URLs to enhance the Contacts app even further.

Adding Copy to Clipboard Rollovers in Contacts App via AppleScript

This marks my last scheduled post for the TUAW for a bit. Hopefully, you'll see more of me here in the future. In the meantime, feel free to reach out to me on Twitter to say "Hello," ask a scripting question or two, suggest a future topic, etc. Until next time, Happy Scripting!

Adding copy-to-clipboard rollovers in Contacts app via AppleScript originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 29 Apr 2013 07:00:00 EST. Please see our terms for use of feeds.

Permalink

Extract App Resource Icons with AppleScript

Extract App Resource Icons with AppleScriptWhether I'm preparing for a demo or writing an article, blog post, book, or technical documentation, I often find myself performing the same set of repetitive steps. I need to navigate into an app's packaged resources folder, find one or more icon files, occasionally convert them to PNG and scale them, and add them to my document, Keynote presentation, etc. Fortunately, this doesn't need to be a manual process each time, thanks to the following AppleScript.

Creating the Script

1. Launch AppleScript Editor (in /Applications/Utilities) and create a new script document.

2. Enter the following script into the document.

NOTE: If you have any trouble following along, you can download the completed script here.

3. Run the script from AppleScript Editor, save it as an app, or add it to your script menu.

Running the Script

When you run the script, you're first asked to select an app from which to extract icons. Make your selection and click Choose.

Extract App Resource Icons with AppleScript

The script looks inside the app's /Contents/Resources folder for any files with an extension of .icns. If multiple files are found, it allows you to select the ones you want to extract. The default is all of them.

Extract App Resource Icons with AppleScript

Next, the script gives you the option to extract the .icns files themselves, or PNG versions. Click the button to make your choice.

Extract App Resource Icons with AppleScript

If you click the PNG button, then you're given a choice of sizes to create. You might not need the full sized icons, for example. You might only need 256x256 icons.

Extract App Resource Icons with AppleScript

Depending on the options you chose, the script extracts the .icns files, or it converts the .icns files to PNG and scales them, as needed. You're notified when the icons have been extracted, and they're displayed in the Finder for you. Now you can simply drag them to your document, presentation, file, etc., and you're good to go! Happy Scripting!

Extract App Resource Icons with AppleScript

Extract App Resource Icons with AppleScript

Extract App Resource Icons with AppleScript originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 22 Apr 2013 07:00:00 EST. Please see our terms for use of feeds.

Permalink

AppleScripting OmniFocus > Send completed task report to Evernote 2

AppleScripting OmniFocus  Send Completed Task Report to Evernote 2In February, I provided instructions for using AppleScript to send completed task reports from OmniFocus to Evernote. The script was quite well-received by readers, and I've had numerous requests for enhancements. This post provides an updated version of the script, which includes a number of additions. The script now supports full project paths and additional task details including the context, estimated time, start date, modification date, completion date and notes. This additional content is optional, and you can adjust the script to not display it if you wish.

Creating the Script

NOTE: You can download my completed script here.

1. Launch AppleScript Editor (in /Applications/Utilities)

2. Create a new script document and enter the following code:

3. At the top of the script, you can adjust various properties to customize the information that's displayed in the report. Just change any of these property values to false to prevent them from appearing.

AppleScripting OmniFocus  Send Completed Task Report to Evernote 2

Running the Script

You can run the script right from within AppleScript Editor. Or, you can save it and run it from your system-wide script menu, your Dock or wherever else you'd like. When the script runs, just specify the date range you want to include.

AppleScripting OmniFocus  Send Completed Task Report to Evernote 2

The script then creates a report for any tasks completed within that specified range in your Evernote Inbox.

AppleScripting OmniFocus  Send Completed Task Report to Evernote 2

Now, you can quickly generate much more detailed reports of your recently completed OmniFocus activity simply by running the script. Happy Scripting!

AppleScripting OmniFocus > Send completed task report to Evernote 2 originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 15 Apr 2013 07:00:00 EST. Please see our terms for use of feeds.

Permalink

AppleScripting Email > Developing a Quoted Reply Service

AppleScripting Email  Developing a Quoted Reply ServiceA reader recently wrote to me with a problem. Apparently, Microsoft Outlook no longer contains the ability to create quote level chunks of text when replying to messages in plain text format. Why this functionality was removed, I can't say. But, with a little help from AppleScript and Automator, I was able to help the reader to add this functionality back via a Service. Better yet, the Service can be set up to work in any email client, or even system-wide in any app. Here's how you can do it...

Building the Service

1. Launch Automator (in /Applications) and create a new Service workflow.

AppleScripting Email  Developing a Quoted Reply Service

Creating a Service workflow in Automator

2. Configure the workflow (at the top) to process selected text in any application, or your favorite email client, such as Mail or Outlook. Then, select the "Output replaces selected text" checkbox.

AppleScripting Email  Developing a Quoted Reply Service

In this screenshot, the Service is set to appear only in the Outlook app.

3. Find and add the Run AppleScript action to the workflow. It should link up with the header, indicating that it receives text as input. Enter the following script into the action.

Note: If you get stuck, you can download the completed script and workflow here.

AppleScripting Email  Developing a Quoted Reply Service

Example of the completed workflow

4. The script above is set to limit lines to a maximum of 42 characters. If you want longer lines, go ahead and adjust this in the script. Just set the theMaxLineLength variable to the desired length. Also, note that this is a guideline. The script tries not to break words in the middle. So, if an extra long word is encountered, you may still have lines longer than the maximum length.

5. Save the workflow as Email > Quote Selected Text. Automator puts it where it needs to go.

AppleScripting Email  Developing a Quoted Reply Service

Saving the Service workflow

Using the Service

Now, anytime you're in your email app and want to create quoted text in a plain text message, just select the desired text. Right-click it (or Option+Click it) to display the contextual menu. Then, select Services > Email > Quote Selected Text. Again, this is intended for plain text messages. It will probably generate inconsistent results with HTML formatted text.

AppleScripting Email  Developing a Quoted Reply Service

Triggering the workflow from the Services contextual menu in Outlook to process selected text in a message

If you don't see the Services menu in the contextual menu, then whatever app you're using may not support contextual Services. In this case, try triggering the workflow from the App > Services menu instead.

AppleScripting Email  Developing a Quoted Reply Service

Triggering the workflow from the Application > Services menu

If all goes well, your selected text is passed to the Service workflow, and the processed quoted text is inserted. Happy Scripting!

AppleScripting Email  Developing a Quoted Reply Service

A message containing processed text

AppleScripting Email > Developing a Quoted Reply Service originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 08 Apr 2013 08:00:00 EST. Please see our terms for use of feeds.

Permalink

Prank crashes iMessages

Late last week, several iOS developers were hit with a denial of service attack that used Apple iMessages as the vector. According to a report in The Next Web, Grant Paul (chpawn), iH8sn0w and a half-dozen other developers were flooded with text messages that crashed the iMessages app on iOS.

The person or group behind the attack is not known, but The Next Web believes it originated with a Twitter account that sells UDIDs and provisioning profiles to iOS owners who want to sideload pirated apps. The attacker likely used the OS X Messages app and Applescript to automate the sending of text messages. When the attack was in full swing, the recipient is forced to clear a non-stop stream of notifications and messages.

Unforunately, there is no way for a user to stop an influx of messages destined for their inbox. Once your iMessage ID is known publicly, anyone can send you an iMessage. Because there is no option to block messages from a specific iMessage sender, you are forced to either read every incoming message or turn off iMessages completely.

This problem is compounded in iOS 6 and OS X Mountain Lion as Apple allows you to associate both your phone number and your email address with your iMessage ID. Phone numbers are usually kept private, but an email address can be easy to find with just a bit of Googling. If a malicious person discovers your iMessages email, there is no way to stop him or her from clogging your inbox with messages. Hopefully, Apple reads these reports and develops a way to detect and shut off this bulk spamming before it hits the recipient's devices.

For a user, the best way to avoid this type of attack is to keep your iMessage email and phone number out of the public realm. If possible, use a public email address for your website and a private one for your iMessage ID. If your iMessage email is already out there, you can always disable receiving iMessages to that email address.

Prank crashes iMessages

On iOS, you can go to Settings > Messages > Send & Receive to change the numbers and email addresses that can receive a message. On OS X, open the Messages app and select "Messages" from the menu. Then select Preferences and click on the Accounts tab. Click on your iMessage ID and make sure your email address is not selected under the "You can be reached for messages at:" heading.

Prank crashes iMessages originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 01 Apr 2013 12:00:00 EST. Please see our terms for use of feeds.

Source

AppleScripting Microsoft Outlook > Announce New Emails By Voice

AppleScripting Microsoft Outlook  Announce New Emails By VoiceIn my last post, I demonstrated how to write an AppleScript that verbally announces when new emails arrive in Mail. Some readers asked whether the same thing could be accomplished with Microsoft Outlook. It certainly can. Here's how...

Creating and Installing the Script

1. Launch AppleScript Editor (in /Applications/Utilities) and create a new script document.

2. Enter the following script into the document.

NOTE: If you have any trouble following along, you can download the completed script here.

NOTE: This script was written and tested with Microsoft Outlook 2011, version 14.3.2, running in OS X 10.8.3, Mountain Lion. You can test the script by running it in AppleScript Editor. Select a message or two in Outlook. Then, return to AppleScript Editor and click Run in the script document's window.

3. Make any adjustments to the properties at the top of the script to customize its behavior. For example, if you don't want the script to raise your volume if it's too low, change the raiseVolumeIfNeeded property value to false. If you don't want the script to read the first few paragraphs of each message to you, set the readFirstParagraphsOfEachMessage property value to false.

AppleScripting Microsoft Outlook  Announce New Emails By Voice

Modifiable Properties in the Script

4. Save the script in Script format to your Desktop as Outlook > Announce New Emails By Voice.scpt.

AppleScripting Microsoft Outlook  Announce New Emails By Voice

Saving the script to the Desktop

5. Launch Outlook. From its script menu, choose About This Menu... In the dialog that appears, click Open Folder. This opens the Outlook Script Menu Items folder, which is either in your ~Documents/Microsoft User Data folder or your ~/Library/Application Support/Microsoft/Office folder, depending on the version of Office you have installed.

AppleScripting Microsoft Outlook  Announce New Emails By Voice

The Microsoft Outlook Script Menu

AppleScripting Microsoft Outlook  Announce New Emails By Voice

Click the Open Folder button to display the Outlook Script Menu Items folder.

6. Move the Outlook > Announce New Emails By Voice.scpt file from your desktop into the Outlook Script Menu Items folder.

AppleScripting Microsoft Outlook  Announce New Emails By Voice

The Outlook Script Menu Items folder may contain some default scripts provided by Microsoft.

Adding an Email Rule

Now that you've installed the script, you can run it from the script menu in Outlook. But, you really want a script like this to run automatically when new emails arrive. So, you need to configure a rule to do this.

1. Select Tools > Rules... to display the Rules window.

AppleScripting Microsoft Outlook  Announce New Emails By Voice

Outlook's Rules window

2. Click the appropriate type of account, i.e. Exchange, IMAP, POP, and click the + button to create a new rule.

3. Name the rule Announce New Emails By Voice and set it to trigger on All Messages. Set the rule's action to Run AppleScript. Click the Script... button and choose your saved script in the Outlook Script Menu Items folder. Click OK to close the rule.

AppleScripting Microsoft Outlook  Announce New Emails By Voice

The configured rule, set to run your script

Now, whenever a new email arrives for the specified type of account, the rule should trigger your script to announce the new messages. If you want to disable the announcements at any time, just go back to the Rules window and de-select the Enabled checkbox next to the rule. Happy scripting!

AppleScripting Microsoft Outlook  Announce New Emails By Voice

You can disable the announcement script in the Rules window whenever you want

AppleScripting Microsoft Outlook > Announce New Emails By Voice originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 01 Apr 2013 10:00:00 EST. Please see our terms for use of feeds.

Source

Talking to Siri: Remote-controlling your Mac by voice with Siri Listener

In this episode of "Stupid Siri Tricks," I make my iOS devices control a remote Mac. How remote? Well, it should work anywhere on the planet (or off, if you happen to be on the International Space Station) with Wi-Fi or a cellular data connection. If you can take a note with Siri, you can make your Mac do your bidding from wherever you may be.

I was inspired to do this after watching a video by Niles Mitchell in which he uses a 512K Mac with the original Mac Speak application to issue a command to Siri, which then set a chain of events into motion resulting in some files being moved from that ancient Mac to Dropbox.

It occurred to me that he was using the Notes application and iCloud to accomplish all of this. Essentially, you tell Siri to "Write a note", after which you dictate a note and it is synced to all of your devices through iCloud. The lightbulb went on, so I wrote a quick little application in AppleScript to wait for certain notes to appear and then perform actions on the Mac.

One of the more useful things I could think of was the ability to shut down my Mac or at least put it to sleep if I forgot to do so before going on a trip, so I set up my application to look for "Shut down" or "Go to sleep" notes to perform either of those actions. Perhaps I want to do a remote restart? All I have to do is tell Siri "Restart my mac" and it happens. I also built in the ability to see what apps are currently running on my Mac and return them to my iPhone or iPad in another note. The possibilities are endless...

To use this little "Siri Listener" app, just copy the code below and paste it into a blank AppleScript Editor page. Save the code in case you want to add your own customizations at some point, and then Export as an Application, making sure that you check the boxes for "Stay open after run handler" and "Run-only". To make sure your Siri Listener is always available for your commands, make sure you set it to run at startup.

Make sure that you know how to use Siri to take notes. Just press the home button on your favorite iOS device, wait for the Siri prompt, and then say "Write a note". Siri responds with some sort of question about what you want the note to say, after which you can speak the appropriate command.

Note that I wasn't thinking clearly when I wrote my initial script -- I actually have to say "What apps are running question mark" to get the note in the proper format for Siri Listener to act upon. I'm probably going to change it to something more generic like "List my mac apps" to avoid the punctuation.

I was really wishing that the Photo Booth app was scriptable, as it would be possible to have the Mac's camera take a picture and then attach it to a Note for you to view. I can also see that the Siri Listener idea could be the perfect tool for playing pranks on unsuspecting co-workers, but of course you wouldn't do that...

Have fun! And if you come up with some fun and/or productive uses for the Siri Listener, let me know in the comments. Want more Siri tips? There's a book for that.

Talking to Siri: Remote-controlling your Mac by voice with Siri Listener originally appeared on TUAW - The Unofficial Apple Weblog on Wed, 27 Mar 2013 20:00:00 EST. Please see our terms for use of feeds.

Source

AppleScripting Mail > Announce New Emails By Voice

AppleScripting Mail  Announce New Emails By VoiceYou're in the kitchen cooking dinner, or sitting down watching TV, or exercising. Ding! You have a new email. Quickly, run to your Mac to see who it's from. Meh, spam. Ding! Meh, a message from your boss. Ding! Meh. Sure would be nice if Mail could announce who's emailing you. That way, you could just listen for ones you care about. Well, with the help of AppleScript and Mail rules, you can set this up on your own. Think of it as an audible caller ID, but for email.

Setting It Up

1. Launch AppleScript Editor (in /Applications/Utilities) and create a new script document.

2. Enter the following script into the document.

NOTE: if you have any trouble following along, you can download the completed script here.

NOTE: If you wish to test the script, which is always a good idea, you can do so by running it in AppleScript Editor. Just select a message or two in Mail. Then, return to AppleScript Editor and click Run in the script document's window.

3. Make any adjustments to the properties at the top of the script to customize its behavior. For example, if you don't want the script to raise your volume if it's too low, change the raiseVolumeIfNeeded property value to false. If you don't want the script to read the first few paragraphs of each message to you, set the readFirstParagraphsOfEachMessage property value to false.

AppleScripting Mail  Announce New Emails By Voice

Modifiable Properties in the Script

4. Save the script in Script format to your Desktop as Mail > Announce New Emails By Voice.scpt.

AppleScripting Mail  Announce New Emails By Voice

Saving the script to the Desktop

5. Launch Mail, open its Preferences window, and click Rules in the toolbar.

AppleScripting Mail  Announce New Emails By Voice

Mail's Rule Preferences window

6. Click Add Rule to create a Mail rule.

7. Set the rule's description to Announce New Emails by Voice.

8. Set the rule to trigger if any of the following conditions are met: Account matches [Your Account]. If you have multiple accounts, click + and add each one.

9. Set the rule to perform the following action: Run AppleScript. From the list of scripts, choose Open in Finder.

AppleScripting Mail  Announce New Emails By Voice

Configuring the Mail rule

10. Copy the Announce New Emails By Voice.scpt script file from your desktop into the newly opened folder (this folder is ~/Library/Application Scripts/com.apple.mail in Mountain Lion).

AppleScripting Mail  Announce New Emails By Voice

Mail's rule scripts folder in Mountain Lion (in ~/Library/Application Scripts)

11. Go back to Mail and close and save the rule.

AppleScripting Mail  Announce New Emails By Voice

The configured Mail rule, set to run the script

Now, whenever a new message arrives for the accounts you specified, the rule should trigger the script, and the messages should be announced audibly. If you get tired of listening to the announcements or want to mute them, just open up Mail's Preferences > Rules window again and de-select the Active checkbox next to the rule. Happy Scripting!

AppleScripting Mail  Announce New Emails By Voice

You can disable the Mail rule by de-selecting the Action checkbox

AppleScripting Mail > Announce New Emails By Voice originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 25 Mar 2013 08:00:00 EST. Please see our terms for use of feeds.

Source

Triggering AppleScripts from Calendar Alerts in Mountain Lion

Triggering AppleScripts from Calendar Alerts in Mountain LionAppleScripts are great tools for increasing your daily productivity. They're even better when they can be set to run unattended, at night, on weekends or during downtime. In Lion, iCal included a handy option for attaching a script to a calendar event. Just create an event, add a Run Script alarm, point it to the desired script and you're good to go. Things changed in Mountain Lion, though. Presumably for security reasons, the Run Script alarm option was removed from the Calendar app. Despite its removal, however, there are still some ways you can trigger scripts from Calendar events.

Triggering AppleScripts from Calendar Alerts in Mountain Lion

iCal event alarm choices in OS X 10.7 Lion

Triggering AppleScripts from Calendar Alerts in Mountain Lion

Calendar event alarm choices in OS X 10.8 Mountain Lion

Use Automator to Trigger Your AppleScript

Although Apple removed the Run Script alarm option in the Calendar app, Automator's ability to save Calendar Alarm workflows wasn't removed. And, since Automator workflows can trigger AppleScripts, they offer a quick and easy workaround for scheduling scripts. Start by launching Automator and creating a new Calendar Alarm workflow.

Triggering AppleScripts from Calendar Alerts in Mountain Lion

To schedule an Automator workflow, choose the Calendar Alarm template.

To Trigger an AppleScript App

If your script is an app, you just need to set the workflow to launch it. Add the Launch Application action to the workflow. From the application popup menu, choose Other... and navigate to your saved AppleScript app.

Triggering AppleScripts from Calendar Alerts in Mountain Lion

The Launch Application action can be used to launch an AppleScript app.

To Trigger AppleScript Code

If you'd rather not create an app (an app + your Automator workflow means more files to manage), you can embed compiled AppleScript code right within your workflow. Find the Run AppleScript action and drag it to the workflow. Then, insert the desired script code into the action.

Triggering AppleScripts from Calendar Alerts in Mountain Lion

The Run AppleScript action can be set to run code embedded in your Automator workflow.

To Schedule the Script

Once you've got your workflow configured, go ahead and save it. Automator automatically adds it to an Automator calendar (which is created if it doesn't exist yet) in the Calendars app. An Open File alarm is added to the event and set to run the workflow. Now, adjust the start date of the event as needed, put it on a repeating schedule, etc.

Triggering AppleScripts from Calendar Alerts in Mountain Lion

Open File alarms are used to trigger Automator Calendar Alarm workflows.

Use AppleScript to Create a Scheduled Event

If you create an event in the Calendars app and add an Open File alarm, you should find that you're unable to select a saved AppleScript app. You can select a compiled AppleScript file, but this is essentially useless because when the event triggers, the Open File alarm simply causes the compiled script to open in AppleScript editor. Not what you need. What you really need is to open a saved script app. AppleScript to the rescue. To work around the limitation, just run the following script. It asks you to select a saved AppleScript app. It then creates an event at the current date and time on an AppleScripts calendar, which it creates if it doesn't exist already. The script then adds an Open File alarm to the newly created event and sets it to open your selected script app. Yep, that's right. Although you can't manually set an event to open a saved AppleScript app, you can script the process.

NOTE: You can download the complete script below here.

So, there you go. A number of workarounds for triggering scripts from Calendar events in Mountain Lion. So, schedule away! Happy Scripting!

Triggering AppleScripts from Calendar Alerts in Mountain Lion originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 18 Mar 2013 14:00:00 EST. Please see our terms for use of feeds.

Source

More Tips for Troubleshooting Automator Workflows

More Tips for Troubleshooting Automator WorkflowsIn my last post, I shared some useful tips for troubleshooting Automator workflow problems. I didn't cover everything, though. There are lots of other ways you can troubleshoot your workflow. Here are some more tips to help.

1. Use Get Selected Finder Items Wisely

Automator workflows are frequently created to process files and folders. When you save a workflow as an application, you can drag files and folders onto it and they're passed right into the workflow for processing. Other types of workflows behave similarly. Save a Folder Action workflow, for example, and every time new items are added to the folder, they're automatically passed to the workflow for processing.

More Tips for Troubleshooting Automator Workflows

At the top of a workflow, Automator tells you if it receives files and folders as input.

From time to time, however, you may notice that your workflow has processed your files twice, or that it's encountered some kind of obscure error. Often, this is due to the presence of a Get Selected Finder Items action at the beginning of the workflow. As enticing as its name sounds, the Get Selected Finder Items action isn't always needed to process files and folders. Remember, depending on the type of workflow you built, those items may be passed automatically to your workflow. In these cases, the inclusion of the Get Selected Finder Items action causes the dropped items to be appended to themselves. This can result in the items being processed twice or an error. So, what's the solution? Just try removing the Get Selected Finder Items action from the beginning of your workflow. Many times, that one simple change fixes the problem.

More Tips for Troubleshooting Automator Workflows

Don't insert the Get Selected Finder Items action at the start of a workflow if your workflow already receives Finder items as input.

2. Finding Missing Output Files

Imagine this. You run an Automator workflow that takes a PDF and outputs its pages as images. The only problem is that the images never seem to show up. Sound familiar? If you've ever been unable to find files output by a workflow, it may not necessarily mean that your workflow failed. Those files may actually be buried somewhere on your system. This is because some Automator actions generate their output files in hidden temporary folders. The Render PDF Pages as Images action is one example. It extracts the pages of a PDF as image files, gives them unique names, and saves them into a hidden temp folder.

More Tips for Troubleshooting Automator Workflows

Render PDF Pages as Images sneakily outputs files to a hidden folder. Note that it doesn't have an option to select an output folder.

To determine whether this has happened, run your workflow in Automator. Then, open the action's Results area. If there are files or folders listed, you should be able to figure out where they're located by viewing them in list view.

More Tips for Troubleshooting Automator Workflows

An action's Results area tells you if an action really produced a result.

To output the files or folders to the desired location, just insert a Move Finder Items action into your workflow. This should move the items from their secret location to the Desktop or wherever else you choose.

More Tips for Troubleshooting Automator Workflows

Use the Move Finder Items action to move hidden output files someplace more useful.

3. Improving Recorded Task Playback

A great feature of Automator is its ability to record things you do manually, so you can play them back later as part of your workflow. A not so great feature of Automator is its knack for being unable to play back what it records. There are a number of reasons this can happen, and some options for fixing things.

You may have made a mistake while recording. Remember, Automator is watching. So, it picks up your mistakes too. If this happens, try selecting the extra steps in the Watch Me Do action Automator adds to the workflow. Then, press the Delete key to remove them.

More Tips for Troubleshooting Automator Workflows

You can remove recorded steps by selecting and deleting them.

You may have moved too fast, and Automator couldn't keep up. It may have missed some of what you did. You can try to resolve the problem by recording the steps again. This time, take your sweet time.

Automator may be unable to repeat what you did manually. Unfortunately, Automator can't access everything in OS X. It can access a lot, but not everything. If this happened, consider trying a third-party macro utility, such as iKey. It may have greater reach than Automator.

4. Locating Missing Actions

If you've ever launched Automator but have been unable to locate an action that you used in the past, it may not mean that action is entirely gone from your Mac. Automator may just be unable to load it for some reason. For example, maybe the app the action works with isn't installed anymore. You can see what Automator is unable to load by checking the Console app (in /Applications/Utilities). Just open it up, launch Automator, and see what shows up in the Console.

More Tips for Troubleshooting Automator Workflows

The Console app tells you what actions Automator can't load. Here, the Entourage actions weren't loaded because I don't have Entourage installed anymore. I now have Outlook installed.

5. Service Workflows Not Triggering?

Have you created service workflows, but when you trigger them, they don't seem to run? Give them some time. For whatever reason, they may take some time to get going. After one has run, however, subsequent service workflows should run a bit faster.

You may have also noticed that you can assign keyboard shortcuts to Service workflows. If you haven't noticed this, you can do it in System Preferences > Keyboard > Keyboard Shortcuts.

More Tips for Troubleshooting Automator Workflows

Assigning a keyboard shortcut to a Service workflow

Once you've assigned a keyboard shortcut, you may have found that the workflow doesn't run when you press the keyboard shortcut. One possible fix is to manually choose the workflow from the application's Services menu. Then, once it's been triggered for the first time, the keyboard shortcut often starts working again.

Hopefully, these tips and my prior tips have put you on the path to more stable and reliable workflows. Good luck and Happy Scripting!

More Tips for Troubleshooting Automator Workflows originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 11 Mar 2013 11:30:00 EST. Please see our terms for use of feeds.

Source

Watch a vintage Mac 512K talk to an iMac via Siri

Niles Mitchell has a variety of Apple devices, including an iPhone with Siri, an iMac and a vintage Mac 512K. Using a combination of the old Speak program, AppleScript and iCloud Notes, Mitchell was able to send files from his iMac to his Mac 512K via Siri. It's a clever mix of old and new technology that's worth a watch, even just to hear the antiquated sound of a floppy drive working hard to copy files.

You can check out this Siri-mediated conversation in the YouTube video embedded below.

Watch a vintage Mac 512K talk to an iMac via Siri originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 11 Mar 2013 09:00:00 EST. Please see our terms for use of feeds.

Source

Tips for Troubleshooting Automator Workflows

Tips for Troubleshooting Automator WorkflowsAutomator's great for streamlining time consuming and repetitive tasks on your Mac. It's easy. Just launch it, find a few actions, and string them together to form a workflow. Then, run your workflow anytime you want to perform that series of tasks again.

What happens if your workflow doesn't run as you expect, though? Finding and solving problems in Automator is often easier said than done. Suddenly, the simple tool that's supposed to make your life easier has become a real pain in the neck. This week's post covers some things you can do to troubleshoot a finicky Automator workflow, track down the problem, and hopefully solve it, so you can get back to work.

1. Run Saved Workflows in Automator

Automator workflows are saved and run in a variety of ways - as apps, iCal alarms, print plugins, and more. When a saved workflow encounters a problem, however, it may be next to impossible to figure out what went wrong. This is because saved workflows don't really include any diagnostic tools. In some cases, the workflow may even fail silently, without alerting you that something is wrong. Your only indication of a problem may be a lack of the end result you were expecting. Not very helpful, especially in a longer multi-action workflow. When you encounter a problem with a saved workflow, your best bet is to open up the workflow in Automator, and try running it there. By doing so, you'll gain access to some of the techniques described below.

2. Fake Workflow Input

When you run a workflow app or plugin within Automator, you may see an alert indicating that the workflow will not receive input.

Tips for Troubleshooting Automator Workflows

An Automator Input Alert for a Text Service Workflow

This is because, often, saved Automator workflows expect input for processing. For example, a workflow app may expect dropped files or folders as input, a service workflow may expect text as input, or a print plugin may expect PDF files from the print system. In any case, just dismiss the alert and add an action to the beginning of the workflow to retrieve the required type of input. If your workflow processes files, for example, add a Get Specified Finder Items action. If your workflow processes text, add a Get Specified Text action. Whatever you add, just be sure to remove it once you're finished troubleshooting.

Tips for Troubleshooting Automator Workflows

Get Specified Text at the Beginning of a Text Service Workflow

3. Check Action Results

Automator works by passing information to actions for processing. Most actions perform a very specific function. As such, they accept specific types of information as input. And, they produce different types of output. The New TextEdit Document action, for example, wants text as input. It then adds this text to a new TextEdit document, and passes the document as output for further processing.

Often, when a workflow fails or produces an undesired result, it's because actions aren't receiving or producing the expected types of information. To diagnose this problem, click the Results button beneath each action in your workflow. Then, when you run the workflow, you can see exactly what information is being passed from action to action.

Suppose, for example, I have a workflow that should take the contents of a text file and add it to a new TextEdit document. I may try creating my workflow with the following actions:

Get Specified Finder Items - Configured to get a text file Filter Paragraphs - Configured to look for non-empty paragraphs New TextEdit Document

All the actions appear to link up properly, and the workflow may even run without an error. But, the result is not what I want. Rather than the content of the text file being added to the new TextEdit document, the path of the document is added.

Tips for Troubleshooting Automator Workflows

A Misbehaving Text Workflow

Tips for Troubleshooting Automator Workflows

An Undesired Workflow Result

By displaying the result area of each action in the workflow, I can see that a file path was passed to the Filter Paragraphs action as input. I can also see that the same file path was output by the action, rather than the paragraphs I was expecting. This tells me that there's something wrong with the Filter Paragraphs action.

Tips for Troubleshooting Automator Workflows

Action Results Indicate Potential Problems

Checking the action's description area provides additional clues. It tells me the action expects text as input, not files.

Tips for Troubleshooting Automator Workflows

Action Descriptions Specify Input and Output Types

So, in this case, the fix is to insert an action that outputs text, rather than files, before the Filter Paragraphs action.

NOTE: Surprisingly, Automator doesn't include an action for reading text from a file. There are third-party actions available that can do this. Or, as a workaround, you can try using the Combine Text Files action, which receives one or more files as input and outputs their text content.

4. Check Automator's Log

Checking the results of an action doesn't always tell you what went wrong. You may glean a little more information by consulting Automator's log area. Press Command+Option+L or choose View > Log to display it. When you run a workflow, the log area tells you which actions ran, and often indicates problems that were encountered along the way, such as an action that wasn't supplied with the appropriate type of input.

Tips for Troubleshooting Automator Workflows

Automator's Log Area Indicates Successes and Failures

Sometimes, the log tells you that information was converted from one type to another. This is because, in some cases, Automator tries to make incompatible actions work together. This doesn't always work, however, and can result in an error. So, be on the lookout for failed conversions.

5. Step Through Workflows

Running a workflow and checking action results is great, but it's even more useful to check the results of each step of your workflow as it happens. You can do this by stepping through the workflow step by step. Click the Step button in the workflow's toolbar or select Workflow > Step from the menu bar.

Tips for Troubleshooting Automator Workflows

Automator's Step Button

The above techniques may not resolve every problem you encounter with Automator, but they will certainly help you to more easily identify solutions for some. Happy Scripting!

Tips for Troubleshooting Automator Workflows originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 04 Mar 2013 07:30:00 EST. Please see our terms for use of feeds.

Permalink

AppleScript Productivity > Create OmniFocus Followups from Contacts

AppleScript Productivity  Create OmniFocus Followups from ContactsAs an OmniFocus for Mac user, it's important that I can quickly create tasks at any time, in any app. OmniFocus makes this pretty easy, by providing integration with OS X Mail, a keyboard shortcut for clipping content in apps such as Safari, a system-wide Quick Entry window and a Services menu item. One feature OmniFocus lacks, however, is direct integration with the Contacts app. Suppose I am in Contacts, for example, and I need to schedule a followup phone call or email to one of my clients? Sure, I could bring up the Quick Entry window and enter the task, but I want something a bit more streamlined. I can accomplish just what I need by writing some custom AppleScripts. The following two examples demonstrate how to write AppleScript-based plug-ins for the Contacts app, which add OmniFocus followup options right into the email and phone number popup menus of your contacts.

Note: If you have any trouble following along, you can download both of the scripts outlined in this post here.

Creating the Email Followup Script Plug-In

1. Quit the Contacts app.

2. Launch AppleScript Editor in /Applications/Utilities and create a new script document.

3. Insert the following code:

4. Save it as a script named Contacts > Email Follow Up with OmniFocus.scpt into the ~/Library/Address Book Plug-Ins folder in your home directory. If this folder doesn't already exist, go ahead and create it.

AppleScript Productivity  Create OmniFocus Followups from Contacts

Saving the Script into the Address Book Plug-Ins folder

AppleScript Productivity  Create OmniFocus Followups from Contacts

The Address Book Plug-Ins folder in ~/Library

Creating an OmniFocus Email Followup Task

To give your new plug-in a try, launch the Contacts app and go to a contact. When you hover over the email address field, it becomes highlighted. Click it and choose Follow Up with OmniFocus from the popup menu that appears.

AppleScript Productivity  Create OmniFocus Followups from Contacts

The OmniFocus Quick Entry window appears, and it contains an email follow-up task for the contact, including a note with a clickable email link.

AppleScript Productivity  Create OmniFocus Followups from Contacts

Creating the Phone Call Followup Script Plug-In

The process to create phone call followup plug-in is essentially the same.

1. Quit the Contacts app again.

2. Create another AppleScript Editor document.

3. Insert the following code this time:

4. Save the script as a script named Contacts > Phone Call Follow Up with OmniFocus.scpt into the ~/Library/Address Book Plug-Ins folder in your home directory.

Creating an OmniFocus Phone Call Followup Task

Launch the Contacts app again. This time, click on a contact's phone number field and choose Follow Up with OmniFocus from the popup menu.

AppleScript Productivity  Create OmniFocus Followups from Contacts

Again, OmniFocus' Quick Entry window is displayed. This time, it contains a phone call follow-up task and a note containing the phone number.

AppleScript Productivity  Create OmniFocus Followups from Contacts

Voila, you now have quick OmniFocus integration with Contacts, and you can use it anytime you need to schedule a follow-up.

Until next time, Happy Scripting!

AppleScript Productivity > Create OmniFocus Followups from Contacts originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 25 Feb 2013 08:00:00 EST. Please see our terms for use of feeds.

Permalink

AppleScripting OmniFocus > Send Completed Task Report to Evernote

AppleScripting OmniFocus  Send Completed Task Report to EvernoteI've mentioned before that OmniFocus is my task manager of choice. Each morning, I pull up a list of scheduled tasks for the day, and focus on getting them done. In OmniFocus, I've set up Perspectives (saved window states) for both Due tasks and Completed tasks. What I really want, however, is something that will pull out recently completed tasks and summarize them in Evernote, my note management app of choice. This way, I can maintain a historical log of my progress, and pull out summaries of completed tasks to send to clients. Since this type of integration isn't built into OmniFocus or Evernote, I wrote an AppleScript to do it.

Creating the Script

NOTE: If you have any trouble following along, you can download my completed script here.

1. Launch AppleScript Editor (in /Applications/Utilities)

2. If your system-wide script menu isn't enabled already, go into AppleScript Editor's preferences window and turn it on.

AppleScripting OmniFocus  Send Completed Task Report to Evernote

3. Create a new script document and enter the following code:

4. Bring OmniFocus to the front, and from the system-wide script menu, choose Open Scripts Folder > Open OmniFocus Scripts Folder. This creates the following folder, if it doesn't already exist -- ~/Library/Scripts/Applications/OmniFocus

AppleScripting OmniFocus  Send Completed Task Report to Evernote

5. Go back to AppleScript Editor and save the script as OmniFocus > Prepare Task Completion Report into the ~/Library/Scripts/Applications/OmniFocus folder you opened in the last step.

AppleScripting OmniFocus  Send Completed Task Report to Evernote

Running the Script

Bring OmniFocus to the front. Next, select OmniFocus > Prepare Task Completion Report from the script menu. The script starts by asking for the scope of the report. Your options are to summarize tasks from today, yesterday, this week, last week or this month. Choose one, and click OK.

AppleScripting OmniFocus  Send Completed Task Report to Evernote

AppleScripting OmniFocus  Send Completed Task Report to Evernote

Next, the script retrieves a list of tasks within the specified timeframe, formats them as HTML, brings Evernote to the front, and creates a new note.

AppleScripting OmniFocus  Send Completed Task Report to Evernote

You've now got a summary of recently completed tasks in Evernote. Do you feel productive yet? Until next time, happy scripting!

AppleScripting OmniFocus > Send Completed Task Report to Evernote originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 18 Feb 2013 07:00:00 EST. Please see our terms for use of feeds.

Permalink

Friday Favorite: Using AppleScript to work with tasks in Things 2

A few weeks ago I purchased Things 2 when it was on sale in the Mac App Store. I've used the demo before and have always enjoyed the simplicity of the Things interface and the power of its tagging system.

One difficulty that I faced with Things, though, is its closed environment, which keeps all your tasks inside the app. That's great if you work only with Things, but not so convenient if you want to share your tasks with other apps or other people. You can drag and drop your tasks individually to other apps like OS X Calendar, but the easiest way to export your tasks is to use AppleScript and transfer them in bulk.

One script I regularly use is this export Things to text script from Dexter Ang (thepoch) on github. This script exports the Things database to the desktop as Things Backup.txt. You can tweak the script to export certain parts of the Things database like your Today tasks or Next tasks. This is very handy as you can then edit the text file and upload it to Google Docs or any other app that'll import and format a text document.

Another one of my favorite scripts is this Reminder export script from NightLion.net. This script lets you export all the tasks in your Today list and import them into the OS X Reminders app. I've been using this script each morning to pull my tasks down into Reminders, which I then use to set flexible notifications for the tasks.

The last script that I've adopted is this Mail To Things script posted by marekz on the Cultured Code forums. This script lets you select a message in your OS X Mail inbox and send it quickly to Things. The task will appear in your Things Inbox with the subject as the name of the task and a link to the email in the notes.

These are just a few that I have stumbled on during my few weeks with Things. If you have any favorite script, please share them in the comments. If you want to create you own scripts, then you should check out Cultured Code's PDF guide to the using AppleScript with Things as well as our growing list of AppleScripts for OS X.

Friday Favorite: Using AppleScript to work with tasks in Things 2 originally appeared on TUAW - The Unofficial Apple Weblog on Fri, 15 Feb 2013 20:00:00 EST. Please see our terms for use of feeds.

Source

AppleScripting Dates > Elapsed Time Calculator

ImageSince Valentine's Day is this week, I thought I would take this opportunity to share an AppleScript I wrote to calculate how long my wife and I have been married. With this baby, I'll never be accused of forgetting how long it's been when our anniversary rolls around. The script determines the elapsed time between now (the current date and time), and a prior date and time (such as our anniversary). It then displays the result in seconds, minutes, hours, days, weeks, months and years.

Note: If you're into the whole "traditional anniversary gift" thing (I'm not), you can find a list of gift categories on Wikipedia.

Creating the Script

Note: If you have any trouble following along, you can download the complete script here.

1. Launch AppleScript Editor in /Applications/Utilities and create a new script document.

2. Insert the following code:

Some notes about this script...

* I used some of the number calculation handlers in the Essential Subroutines section of macosxautomation.com, although, I made some slight modifications to them for the script. If you're interested in learning more about AppleScript, there are some other useful handlers there, as well, and I encourage you to check them out.

* The final display dialog sets as its icon the FavoriteItemsIcon icon file, which is embedded in the CoreTypes bundle in /System/Library/CoreServices. It is, coincidentally enough, a heart.

Using the Script

To use, just run the script within AppleScript Editor, or save it as an application to be launched and run whenever you wish. First, the script asks you to enter a date and, optionally, a time.

Image

Next, the script does its calculations and displays the result. Just take a screenshot of the dialog and send it along to your significant other.

Image

Until next time, Happy Scripting and Happy Valentine's Day Week!

AppleScripting Dates > Elapsed Time Calculator originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 11 Feb 2013 07:30:00 EST. Please see our terms for use of feeds.

Permalink

AppleScripting Notification Center > Scheduling Do Not Disturb

AppleScripting Notification Center  Scheduling Do Not DisturbMountain Lion's Notification Center is great for keeping you in the loop, but it can be a huge distraction when you need to get stuff done. Sometimes, a little peace and quiet is all you need to stay productive.

As you may know, iOS 6 includes a handy Do Not Disturb feature, which can be turned on to disable notifications. It can even be set to automatically enable/disable itself at scheduled intervals. Mountain Lion also lets you disable Notification Center. Just open Notification Center and drag down to access a Show Alerts and Banners toggle switch. Note that this is a temporary setting, and disabled notifications automatically re-enable at midnight.

AppleScripting Notification Center  Scheduling Do Not Disturb

Unlike iOS 6, though, Mountain Lion doesn't give you an option for enabling/disabling notifications on a schedule. At least, it doesn't provide a built-in option for this. With a little customized help from AppleScript, Automator, and the Calendar app, it is possible.

In this post, you'll create two Calendar Alarm Automator workflows, which can be configured to run at scheduled times to enable or disable Notification Center alerts and banners.

Note: If you have any trouble following along, you can download the completed AppleScripts and Automator workflows here.

Building a Workflow to Enable Do Not Disturb (i.e. Disable Notification Center Alerts and Banners)

1. Launch Automator (in your /Applications folder) and create a new Calendar Alarm workflow.

AppleScripting Notification Center  Scheduling Do Not Disturb

2. Search the action library for the Run AppleScript action and drag it to the workflow area.

3. Replace the pre-filled AppleScript code in the Run AppleScript action with the following:

The script writes to Notification Center's property list file and enables Do Not Disturb mode. It then quits and relaunches Notification Center in order for the change to go into effect.

AppleScripting Notification Center  Scheduling Do Not Disturb

4. You're finished building the workflow, so go ahead and save it as Enable Do Not Disturb.

AppleScripting Notification Center  Scheduling Do Not Disturb

5. When you save the workflow, Automator puts it where it needs to go (the ~/Library/Workflows/Applications/Calendar folder). The Calendar app launches and a new event is created in an Automator calendar, which Automator creates if it doesn't already exist. The event should be configured with an Open File alarm that's set to run the workflow. Schedule the event for the desired time, such as every weekday morning at 6 AM.

AppleScripting Notification Center  Scheduling Do Not Disturb

Now, every time the event occurs, the alarm should launch the workflow and Notification Center should be disabled. As I mentioned earlier, Notification Center automatically re-enables each day at midnight. So, if you plan to schedule Do Not Disturb overnight, then you'll need to create an additional event that disables it again at 12:01 AM.

Building a Workflow to Disable Do Not Disturb (i.e. Re-Enable Notification Center Alerts and Banners)

Now that you've got a workflow to disable Notification Center, you probably want one to re-enable it.

1. Create another new Calendar Alarm workflow in Automator.

2. Search the action library for the Run AppleScript action again and drag it to the workflow area.

3. This time, replace the existing placeholder script in the Run AppleScript action with the following code:

This code updates Notification Center's property list file to disable Do Not Disturb. Then, it relaunches Notification Center for the change to take effect.

AppleScripting Notification Center  Scheduling Do Not Disturb

4. The workflow is done, so save it as Disable Do Not Disturb.

AppleScripting Notification Center  Scheduling Do Not Disturb

5. The Calendar app should launch again and another event should be added to the Automator calendar. This event should be configured with an Open File alarm that's set to open the Disable Do Not Disturb workflow. Set it to run on the desired schedule, such as every weekday morning at 9 AM.

AppleScripting Notification Center  Scheduling Do Not Disturb

If everything has gone according to plan, you should now have Do Not Disturb workflows that disable and re-enable Notification Center alerts and banners at the desired times. Use your alert-free time wisely. Until next time, happy scripting!

AppleScripting Notification Center > Scheduling Do Not Disturb originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 04 Feb 2013 07:00:00 EST. Please see our terms for use of feeds.

Permalink

AppleScripting Evernote > Embedded Image Scaler

AppleScripting Evernote  Embedded Image ScalerI'm a big fan of Evernote. I use it for archiving ideas, writing articles / blog posts and lots more. I often insert screenshots and other large images into my notes. Screenshots can be pretty big, and I usually don't want giant images filling up my notes. I keep wishing Evernote offered a way to resize embedded images, so I could insert thumbnails. At the moment, it doesn't. So, I decided to write my own app to resize embedded images. Here's how you can do the same...

Creating the Script App

My script app uses Image Events, a background app in OS X, to do the scaling. So, no third-party software (other than Evernote) is needed for this to work.

Note: If you have any trouble following along, don't worry, you can download the complete script app here.

1. Launch AppleScript Editor and create a new script document containing the following script:

If you're familiar with AppleScript, then you'll notice this script uses an open handler, making it a droplet. When triggered to process an embedded image in an Evernote note, the image is actually passed as if it was dropped on the script app.

2. Save the script as an application named Evernote > Scale Embedded Images to your Applications folder or another folder of your choice.

AppleScripting Evernote  Embedded Image Scaler

3. Go to the saved script app and Control+Click on it to reveal the Finder's contextual menu. Choose Show Package Contents to view the contents of the saved app bundle.

AppleScripting Evernote  Embedded Image Scaler

4. Navigate to the Contents folder within the script's bundle and open the Info.plist file in TextEdit, TextWrangler or your other favorite text editor.

AppleScripting Evernote  Embedded Image Scaler

5. Change the CFBundleDocumentTypes key's array to the following:

This Info.plist change sets the script app to only accept JPEGs, PNGs and TIFFs, and for the script app to appear as an image editor. Image Events can process other types of images too, including BMP, GIF, PSD and PICT. So, if you think you may be embedding those types of images in your notes, go ahead and add extensions for them too.

6. Save and close the edited Info.plist.

You're done. The script app is ready for use.

Resizing Embedded Images in Evernote

Please note that your script app scales embedded images in Evernote notes. When an image is scaled, you can't revert back to the unscaled version. So, be pretty darn sure you want to scale an image before triggering the script.

1. Open an Evernote note containing an embedded image.

AppleScripting Evernote  Embedded Image Scaler

2. Control+Click on an embedded image and choose Open With. You should see your script app in the list of supported apps. Choose Evernote > Scale Embedded Images.

AppleScripting Evernote  Embedded Image Scaler

Evernote launches the script app and passes it the selected embedded image.

3. When prompted, choose the desired size. Options are Low (320px on the longest side), Medium (640px) or High (1280px). Or, you can select Custom to enter another size.

AppleScripting Evernote  Embedded Image Scaler

The script opens the embedded image, scales it accordingly and saves it. Evernote detects that the image has been changed, and updates the note to reflect the new scaled version.

AppleScripting Evernote  Embedded Image Scaler

Congratulations, you've just expanded Evernote's feature set. Anytime you want a smaller version of an embedded image, your script app is ready to help. Also, while this script is intended for Evernote, you can use it outside of Evernote too. Just drag and drop JPEGs, PNGs or TIFFs onto the script app to scale them too. Until next time, happy scripting!

AppleScripting Evernote > Embedded Image Scaler originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 28 Jan 2013 08:00:00 EST. Please see our terms for use of feeds.

Source

Mac Productivity > 10 TextExpander Date Snippets

Mac Productivity  Ten TextExpander Date SnippetsTextExpander (Smile Software) is a utility I use each and every day on my Mac to save time and increase productivity. One of the things I use it for is formatting and inserting dates and times -- adding the date or time to a file or folder name, into an email, a document and so on. In this post, I've shared some of my most used date and time snippets. I hope you find them as useful as I do.

If you're not a TextExpander user, I encourage you to give it a try. You can download a trial version on the Smile Software website. Let me give you a little background on how it works. The concept of TextExpander is simple. You start by creating snippets of text. You then assign abbreviations to those snippets. Whenever you type an abbreviation into any app on your Mac, presto! The corresponding snippet is inserted, replacing the abbreviation you typed. TextExpander also includes some power-user features, such as macros, which let you to insert variable information into your snippets, like dates and times. This is what I'm sharing here -- some of the macros I use for inserting dates.

I've provided a brief description of each snippet, as well as the snippet code (the macro), and the abbreviation I use. Feel free to adjust accordingly to meet your own needs.

1. Current Date -- Long: This snippet actually comes with TextExpander as an example. It's used to insert the current date in Month, D, YYYY format, i.e. January 9, 2013. I consider this a long date, and changed the abbreviation, so as not to conflict with my other snippets.

Mac Productivity  Ten TextExpander Date Snippets

Snippet: %B %e, %Y Abbreviation: CDATEL

2. Current Date -- Short: This snippet inserts the current date in YYYY-DD-MM format, i.e. 2013-01-09. This is a good format to use when applying dates to file and folder names, as it allows them to be sorted by year, month and day.

Snippet: %Y-%m-%d Abbreviation: CDATES

3. Current Time - Long - This snippet inserts the current time in H:M:SS AM/PM format, i.e. 10:00:00 AM. While this format is good for inserting into emails or documents, it's not so good to use on file or folder names, due to its use of colons.

Snippet: %1I:%M:%S %p Abbreviation: CTIMEL

4. Current Time -- Short: This snippet inserts the current time in HH-MM-SS format, i.e. 10-00-00. This is a good format to use when applying times to file and folder names, as it doesn't contain any colons. It also uses 24-hour time, in order to avoid potential file name conflicts.

Snippet: %H-%M-%S Abbreviation: CTIMES

5. Month and Year: This snippet inserts the current month and year, in Month YYYY format, i.e. January 2013. I often need to reference the current month in this manner when writing emails.

Snippet: %B %Y Abbreviation: MDATE

6. Yesterday: The following snippet subtracts one day from the current date and inserts it in YYYY-MM-DD format, i.e. 2013-01-08.

Snippet: %@-1D%Y-%m-%d Abbreviation: YDATE

7. Tomorrow: The following snippet adds one day to the current date, and inserts it in YYYY-MM-DD format, i.e. 2013-01-10.

Snippet: %@+1D%Y-%m-%d Abbreviation: TDATE

8. Future Date: The following snippet can be customized to add a specified number of days to the current date, in YYYY-DD-MM format. I have several versions of this snippet for two, three and four days in the future.

Snippet: %@+(INSERT NUMBER OF DAYS HERE)D%Y-%m-%dd Abbreviation: FDATE(NUMBER OF DAYS)

I.e. For two days in the future:

Snippet: %@+2D%Y-%m-%dd Abbreviation: FDATE2

9. Next Sunday: I often need to refer to next Sunday in emails, invoices and so on in YYYY-MM-DD format. This goes beyond what TextExpander's built-in macros can do, so I resort to AppleScript. Just set the content type of your snippet to AppleScript, and paste in the following code:

Mac Productivity  Ten TextExpander Date Snippets

Snippet:

Abbreviation: NEXTSUN

10. Current Week Range: I also sometimes need to insert a range of dates representing the current week. Again, this goes beyond the capabilities of TextExpander's build-in macros, so I use AppleScript. Again, set the content type to AppleScript, and paste in the following:

Mac Productivity  Ten TextExpander Date Snippets

Snippet:

Abbreviation: CWEEK

Mac Productivity > 10 TextExpander Date Snippets originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 21 Jan 2013 07:00:00 EST. Please see our terms for use of feeds.

Permalink