Need Some Help? Have a Tip to Share?

Email me at MacTipper@gmail.com, or, leave a comment!

Subscribe To Our FREE RSS Feed!

Don't miss out on any posts from the Concise MacTipper Blog.

Thursday, April 30, 2009

Quickly Open Applications From Terminal

If you're writing a bash script, there is a really simple way to open an application from Terminal. Just use the "open" command in conjunction with the -a flag:

open -a Safari


Another cool thing you can do with this is open multiple instances of an application. Just tack on the -n flag:

open -n -a Safari

Wednesday, April 29, 2009

Make an iPhoto Smart Album of Untagged Faces

A smart album in iPhoto containing all your unnamed faces makes it easy to name your photos. To create such an album hit Cmd-Option-N to create a new smart album. Give it a name and set the criteria to "Face is unnamed".

[Via]

Tuesday, April 28, 2009

Use a Keyboard Shortcut to Open Files in Non-Default Apps

It is possible to open a file in its default application using Cmd-O. Using System Preferences or an AppleScript it is possible to make a keyboard shortcut to open a selected file in the file's non-default application.

Method 1: Make a Keyboard Shortcut in System Preferences

Step 1: Open System Preferences and go to the Keyboard & Mouse settings.

Step 2: Click on the "Keyboard Shortcuts" section.

Step 3: Click on the + symbol in the lower-left corner.



Step 4: Make the keyboard shortcut for "Finder" with the menu title of the app you want to open it with "QuickTime Player.app" for example) and hit a keyboard shortcut.





Method 2: Use an AppleScript in Conjunction with a Keyboard Macro Program

This method is much more stable and is easily adaptable. Use the following AppleScript to open the selected Finder items in the application named in the first property:

(Click here to open the script in Script Editor)

property the_app : "QuickTime Player"

tell application "Finder"
set the_selection to the selection
end tell

repeat with each_item in the_selection
do shell script ("open -a " & (quoted form of the_app) & space & (quoted form of (POSIX path of (each_item as alias))))
end repeat

Monday, April 27, 2009

Make an AppleScript Application a Default Application

It is not possible, by default, to set an AppleScript as a default application for a file. Using this trick though, you can.

Step 1: Save your AppleScript as an "Application Bundle" and go to it in Finder.

Step 2: Right click on your AppleScript and select "Show Package Contents".

Step 3: Open the ./Contents/info.plist file in TextEdit.



Step 4: Look for this section (it should be near the top) :

<key>CFBundleDevelopmentRegion</key>
<string>English</string>


Step 5: Immeadeatly after that section, paste in and edit this:
<key>CFBundleIdentifier</key>
<string>com.yourname.appname</string>


It should look like this (relevant section highlighted) :



Step 6: Save the Info.plist file by hitting Cmd-S.

Step 7: Restart your Mac.

Step 8: Find a file of the type you intend to set the default app for (for me, a DIVX file); right click on it and select "Get Info" or hit Cmd-I.

Step 9: Go to the "Open With" section of the get info window and select "Other…" from the drop-down menu. Find and select your AppleScript.



Step 10: Finally, click on the "Change All…" button. You'll be asked to confirm.

Sunday, April 26, 2009

Welcome2Mac: Managing Your Desktop Background

Welcome2Mac is The MacTipper Blog's weekly tip where all the people new to Apple's latest operating system can get Mac tips to help them better use Mac OS X.

In this week's Welcome2Mac we're going to take a look at managing your Desktop background.

Set Your Desktop Background
To set your desktop background, go to System Preferences and click on the "Desktop & Screen Saver" section:



Click on the "Desktop" section:



Finally, choose a background image to use.


Quickly Get to the Desktop & Screen Saver Prefs
Just right click on your desktop and select "Change Desktop Background…"




Quickly Change Your Desktop Background
If you already have the image file located in Finder, you can just drag-and-drop the file onto the Desktop background preview section.




Change Your Desktop Background From Safari
Apple finally added this feature in Leopard. You can right-click on any image in Safari and select "Use Image as Desktop Picture".




Disable the Desktop Icons
There is a simple Terminal command to disable the desktop icons so you can see your lovely desktop background:

defaults write com.apple.finder CreateDesktop -bool false; killall Finder


This will disable the icons and restart Finder.
However, this will also disable the previously mentioned tip of right-clicking on your desktop to change your desktop background. Use this Terminal command to re-enable the desktop icons:

defaults write com.apple.finder CreateDesktop -bool true; killall Finder

Friday, April 24, 2009

AppleScript Snippets: Get Front App, Replace Text, Check for New Mail

Here are some AppleScript snippets you might find helpful:

Get Front Application
This is helpful if you want to display a dialog box in the front app:

tell application "System Events" to set Front_App to name of (first application process whose frontmost is true)
tell application Front_App
display dialog "Duuuuude."
end tell



Search and Replace in a String
This is a basic find string and replace function for AppleScript. Just make sure you edit the first three lines and the last line.

set searched_string to the_original_string_variable
set search_for to "this is what you want to find"
set replace_with to "this is what you want to replace with"

set the_new_string to searched_string
if searched_string contains search_for then
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to search_for
set the_text_list to every text item of searched_string
set AppleScript's text item delimiters to replace_with
set the_new_string to the_text_list as string
set AppleScript's text item delimiters to old_delims
end if
set the_original_string_variable to the_new_string



Send an Email
This isn't the easiest one to figure out, just make sure you edit the first three lines:

set theSender to "send_from@example.com"
set recipAddress to "send_to@example.com"
set theSubject to ("The Subject Line")

tell application "Mail"
set newmessage to make new outgoing message
tell newmessage
set sender to theSender
set subject to theSubject
make new to recipient with properties {address:recipAddress}
end tell
set visible of newmessage to true
send newmessage
end tell

Thursday, April 23, 2009

Click Scroll in Firefox

Firefox only: Click on the center mouse button while hovering over some text or other non-clickable interface element in Firefox. A small circle with two or four arrows will appear. Move your mouse away from the circle in the direction you wish to scroll.

Wednesday, April 22, 2009

"Move Again" in Apple Mail

It is quite easy to move emails to the same folder multiple times in a row in Apple Mail. First, move an email to the folder you desire. Then, select the next email and hit Cmd-Option-T or go to the Message menu and select "Move to '[Mailbox name]' Again".

Tuesday, April 21, 2009

Cursorcerer: Make Your Mouse Vanish


Cursorcerer allows you to define a keyboard shortcut to make your mouse vanish. If you disable the Front Row keyboard shortcut then you can use Cmd-Escape as the mouse banishing shortcut.



[Download Cursorcerer]

Monday, April 20, 2009

Control the Calender Widget with the Keyboard

You can navigate the Calender widget with the keyboard arrows. Start by clicking on the widget. (I would suggest the actual calender section.) Then, use the left and right arrow keys to move forward and backwards by a month. Use the up and down arrow keys to navigate by year.

Sunday, April 19, 2009

Welcome2Mac: Concerning PDF's

Welcome2Mac is The MacTipper Blog's weekly tip where all the people new to Apple's latest operating system can get Mac tips to help them better use Mac OS X.

In this week's Welcome2Mac, we'll be taking a look at easily saving and emailing a document as a PDF, deleting pages from PDF's in Preview, and adding text onto a PDF using Skim.


It is really quite easy to email a document to somebody as a PDF. Just hit Cmd-P to open the print dialog box, then click on the "PDF" button in the lower-left corner. Finally, select the "Mail PDF" option and you're good to go. (You'll also notice an option in that menu to "Save PDF".)




Need to get rid of a page from a PDF? Start by opening it in Preview and finding the page. Then, select the page and hit Cmd-Delete. If you didn't want to delete that page, hit Cmd-Z or go to the Edit menu and select "Undo".


As I mentioned previously, it is possible to fill out PDF's for free using Skim. If you have a PDF form you need to fill out, skim can do that job. (Albeit, Skim is probably not the best tool to do this.)

Once you've downloaded and added Skim to your Applications folder, right click on any PDF and select Open With > Skim.app. From there, hit Cmd-5 to switch to the text tool. Click and drag to create a text box.

Friday, April 17, 2009

Normal Zoom Function in iTunes

The zoom button in iTunes switches between the Miniplayer and the normal player. While you might claim that this is "zooming", it is not the same kind of zooming we see in Safari, TextEdit, Mail, iCal, Keynote, Pages, etc.

However, if you hold down the option key when clicking on the zoom button, the iTunes window will zoom like you would expect.

If you are using Windows, hold down the shift key instead.

[Via]

Thursday, April 16, 2009

Change Ethernet Status With a Keyboard Shortcut

It is possible to toggle your Ethernet on and off using Terminal:

Step 1: First we need to find out the name of your ethernet connection. To do this run this terminal command:

networksetup -listallnetworkservices

Look for the item that you're using for internet. (Most likely either "Ethernet" or "Built-in Ethernet".)

Step 2: Now that you know your ethernet's name, use this terminal command to disable it:

networksetup -setnetworkserviceenabled Ethernet off

and use this command to re-enable your Ethernet:

networksetup -setnetworkserviceenabled Ethernet on

This can be adapted to an AppleScript like so:

property the_password : "An Admin Password"
property network_name : "Ethernet"

set enabled_q to do shell script "networksetup -getnetworkserviceenabled '" & network_name & "'"
if enabled_q is "Enabled" then
do shell script "networksetup -setnetworkserviceenabled '" & network_name & "' off" password the_password with administrator privileges
return "off"
else
do shell script "networksetup -setnetworkserviceenabled '" & network_name & "' on" password the_password with administrator privileges
return "on"
end if


Don't forget to edit the first two properties.

Wednesday, April 15, 2009

Add a Link to an Email in Apple Mail

Here's how to add a link to an email in Apple Mail:

Step 1: Select some text.

Step 2: Right-click on the text.

Step 3: Go to the "Link" submenu and select "Add…"

Tuesday, April 14, 2009

Get the Text of Websites Cached by Safari

Safari caches almost all of the text of websites you visit. This allows you to search for sites you've visited using Spotlight. Using TextEdit, you can read the contents of the cache file, here's how:

Step 1: Perform a Spotlight search for the site text you want.

Step 2: Select the site you want the text of and hit Cmd-R to reveal the file in Finder. Finder will open up and a file with ".webhistory" as its extension will be selected.

Step 3: Open the file using TextEdit. The text of the website will be there in one paragraph.

Monday, April 13, 2009

Quickly Paste Long Lists Using Applescript

The goal of this tip is to take a list of items (separated by carriage returns) and paste each item into different text boxes in iMovie (although, you could easily use it for other things.) Before we start, you might want to download the final script.



Step 1: Create a list of items you want to paste into text boxes. Break up each item in the list with a carriage return. (If you have items that are multiple paragraphs, the script can be adjusted to fit that.)

Step 2: Open up Script Editor.

Step 3: First, we need to identify the list. So type:

property the_list : "

and paste in the list. Add a second double-quote to close it off. If there are any double-quotes in your list, escape them by adding a "\" right before it.


Step 4: Now that we've identified the list, we need to get every text item of the_list. To do this, use AppleScript's text item delimiters. AppleScript's TID's tell AppleScript where to break up the text. The default is "" or nothing. So, to split up the_list, we'll set AppleScript's TID's to a carriage return:

set AppleScript's text item delimiters to "
"


Next, we'll break up the_list:

set the_text_list to every text item of the_list

This will give us a list of every paragraph in the_list without any carriage returns. Note that whenever we change AppleScript's TID's, we need to set them back again:

set applescript's text item delimiters to ""


Step 5: Now it gets pretty easy. We need to get the first item on the list, make the clipboard be that item, then get rid of the first item. (This way, the new first item is the old second item.) We need to keep in mind error checking, so we'll use something like this:

set the_text_item to item 1 of the_text_list
try
set the_text_list to items 2 thru -1 of the_text_list
on error err
log err
set the_text_list to "End of list."
end try
set the clipboard to the_text_item


Here's a line by line rundown of this snippet:
Line 1: get the first item on the list. (This is always item 1.)
Line 2: when we use try, if something breaks then the script will keep rolling. (See line 4.)
Like 3: This deletes the first item of the_text_list by rebuilding the_text_list to not include it.
Line 4: we use "on error err" when we use "try". When something happens, the script will skip everything else in the "try" statement and go straight to the "on error" statement. "err" in this case is the text of the error.
Line 5: we log err (the text of the error) in case something goes wrong. When we log something, it displays the error in the "Event Log" section at the bottom of the window.
Line 6: The reason we get an error is because there is only one item in the_text_list. When this happens, it's the end of the list. So we simply set the_text_list to "end of list". Next time we run the script, this is what the clipboard will be set to.
Line 7: the obligatory "end try" statement.
Line 8: this is how you set the clipboard's contents. Notice that "the_text_item" is from line 1 of this snippet.


Step 6: Now all we need to do is make the_list be the new list. To do this, type:

set AppleScript's text item delimiters to "
"
set the_list to the_text_list as string
set AppleScript's text item delimiters to ""


Once again, we are using AppleScript's TID's. However, this time, we are turning a list into a string. When we do this, AppleScript's TID's are put between each item in the list. Because the_list is a property, its contents will be remembered each time you run the script. (So if we use AppleScript to change the_list to "hello" then it will stay "hello" until we recompile the script at which time it will become whatever the text of the script says it is.)


Step 7: To test out your script, we'll add one more line:

return the clipboard

This ends the script and displays whatever the clipboard is in the "Result" section at the bottom of the window. When we run the script multiple times, this should change to each item of the list. Hit Cmd-R to run it. You should be able to cycle through each item on the list. If you want to run it again, hit Cmd-K to recompile the script. Here's what my final script looks like:



Step 8: We've spent all this time making the script, now all we need to do is plug it into a keyboard macro program like Spark. (If you don't have a keyboard macro program already, Spark is a really easy program for use with AppleScript's.)


Step 9: That's it! You should now know how to use AppleScript's text item delimiters, set the contents of the clipboard, and basic manipulation of lists.

[Download the final script]

Sunday, April 12, 2009

Welcome2Mac: Announce the Time and Label Emails

Welcome2Mac is The MacTipper Blog's weekly tip where all the people new to Apple's latest operating system can get Mac tips to help them better use Mac OS X.

In this week's Welcome2Mac we'll be taking a look at making your Mac say the time at a certain interval and adding color labels to emails in Apple Mail.


Make your Mac announce the time:

Step 1: Open System Preferences.

Step 2: Go to the "Date & Time" preference pane.

Step 3: Click on the "Clock" section.

Step 4: At the bottom of the Clock section is an option to "Announce the time:", check the box next to that and apply the settings as you desire.





How to apply a color label to an email in Apple Mail:

Step 1: Select the email.

Step 2: Hit Cmd-Shift-C to open the color palette.

Step 3: Pick a color and it will be applied to the email.

Friday, April 10, 2009

Display a Notification When Your Mac Connects to WiFi After Waking From Sleep

I have written a script that lets me know when I'm connected to the internet after waking my laptop from sleep. To do this, you will need SleepWatcher by Bernhard Baehr.
Optionally, you can also use Growl for the notifications, however it is not mandatory.


Step 1: Download SleepWatcher and run both installers inside the Disk Image. SleepWatcher is a Daemon (program that runs in the background) that monitors when your Mac wakes from sleep, goes to sleep, or becomes Idle.

Step 2: Open up Script Editor and write a script that you want to run when you have internet available. If you just want your computer to make an alert sound, use:

beep


If you want to display a growl notification, use this script (copy and paste it into Script Editor and run it) to register with growl:

tell application "GrowlHelperApp" to register as application "Wakeup Notification" all notifications {"Internet On"} default notifications {"Internet On"} icon of application "AirPort Utility"


Then use this to actually display the notification:

tell application "GrowlHelperApp" to notify with name "Internet On" title "Internet On" description "The internet is now active." application name "Wakeup Notification"


Save your script somewhere safe.

Step 3: Open up Terminal and type "osascript " (with a space at the end), then drag in the AppleScript file you created. Hit return and your script should run.

Step 4: Open a new Terminal window and type:

nano ~/.wakeup


This will open up a command-line text editor.

Step 5: Copy and paste the following four lines of code into the command line text editor then hit return:

pinggoog=`ping -t 120 -o 74.125.45.100`
if [ `echo $pinggoog | grep -c '100% packet loss'` -gt 0 ] ; then
echo failed
else


Now switch over to your original Terminal window and copy the code you tested in step 3. Switch back to the text editor and paste in the code you copied. Finally, hit return again and add "fi" to the end of the document. In the end, it should look like this:



Step 6: Hit Ctrl-X, then "Y", then hit return. (This exits the text editor, asks if you want to save, then confirms that you want to save it.)

Step 7: At the command prompt, type the following line and hit return:

chmod +x ~/.wakeup



Step 8: Now, to make sure your script works, type in this code and hit return:

~/.wakeup



Step 9: Assuming the previous command ran fine, all should be ready. It is now simply a matter of sleeping your Mac, then waking it again.



[SleepWatcher]

Wednesday, April 8, 2009

Create a Service to Type Special Characters

If you want to type special characters that aren't available using Option or Option-Shift, I've come up with a service to type the appropriate character for me. To do this, you'll need ThisService by Waffle Software.

Once you've downloaded ThisService, open up Script Editor (/Applications/AppleScript/Script Editor.app) and write a script like this:

on process(the_selection)
return "♥"
end process




Just replace the ♥ symbol in the above AppleScript with the desired symbol. (You can find the symbol by going to the Edit menu and selecting "Special Characters…" Then use the search box in the lower left corner of the Special Characters palette.)



Once you've made the script, save it somewhere and open up ThisService.

Fill out the ThisService window with a Name for your service, choose the AppleScript you created previously, set the "Type" to "Produces Output", and set it to include a copy of the script. Finally, click on the "Create Service" button.



Now it's simply a matter of creating a keyboard shortcut for your service menu item.

Tuesday, April 7, 2009

DropBox: Sync Files Across Computers

DropBox is a free application that allows you to sync files over computers across the internet. In addition, you can access your files from a web interface as well.

To use DropBox, download the installer and install the application. Upon launching, you will be asked to create an account or enter in your account information. If this is your first time using it, create an account and run the installer.

Once you've installed DropBox, it's simply a matter of putting files into your DropBox folder. These files will be synced with the DropBox servers. If you set up DropBox on any other computers, the files will be synced with those computers' DropBox folders as well.

[DropBox]

Monday, April 6, 2009

Various Macro AppleScripts

A keyboard macro program such as Spark can often use an AppleScript as one of its macros. I've been using Spark for quite a while and here are some of the scripts I use every day:

Black Screen
A SystemUI script to set the brightness of your monitor to 0.

tell application "System Preferences"
run
set current pane to pane "com.apple.preference.displays"
tell application "System Events"
set value of slider 1 of group 2 of tab group 1 of window "Color LCD" of process "System Preferences" to 0.0
end tell
quit
end tell



Super-Charged "Check for New Mail"

This script will check to see if Mail.app is running. If it isn't, the script launches Mail in the background then checks for new mail. If it is, the script just checks for new mail.

tell application "System Events"
if ((get name of the processes) does not contain "Mail") then
tell application "Mail"
run
end tell
end if
end tell

tell application "Mail"
check for new mail
end tell



Super-Charged Application Launcher
I mainly use this one for iTunes, but it is easily adaptable to some other applications. This script will launch iTunes in the foreground. But, if you run it again and iTunes is the front application, it will hide iTunes.

property app_name : "iTunes"

tell application "System Events"
set front_app to name of (first application process whose frontmost is true)
end tell

if front_app is app_name then
tell application "System Events" to set visible of first application process whose frontmost is true to false
else
tell application app_name to activate
end if



Super-Charged iTunes Play/Pause
This script will play or pause iTunes depending upon whether iTunes is paused or playing. The special part about this script is that if your volume is 0, then the script will raise your volume a little to make sure you hear the music:

tell application "iTunes" to set play_state to player state as string
if play_state is "paused" then

if (output volume of (get volume settings)) is 0 then set volume 2
tell application "iTunes" to play
else
tell application "iTunes" to pause
end if



Volume Management Scripts
I have three scripts related to managing my Mac's volume. The first script sets the volume to the maximum setting:

set volume 10

The second script is a mute script. Unlike traditional mute, this script pauses iTunes if I mute the volume. In addition, it will beep after muting or un-muting the volume.

set mute_status to (item -1 of ((get volume settings) as list))

if mute_status is false then
set volume with output muted
set mute_status to 1
tell application "System Events"
if (name of every process as string) contains "iTunes" then
tell application "iTunes" to pause
end if
end tell
else if mute_status is true then
set volume without output muted
set mute_status to 0
tell application "System Events"
if (name of every process as string) contains "iTunes" then
tell application "iTunes" to play
end if
end tell
end if

beep


My third volume management script sets the volume output to 0, pauses iTunes, and beeps:

set volume 0
tell application "System Events"
if (name of every process as string) contains "iTunes" then
tell application "iTunes" to pause
end if
end tell

beep



Full Screen Safari Window
This script is pretty much summed up in the title. Make sure you edit the second line so that the last two items in the list (currently 1440 and 900) are the x and y dimensions of your screen. (If you have a MacBook, it is probably 1280 and 800 respectively.)

>tell application "Safari"
set the bounds of the first window to {0, 0, 1440, 900}
end tell



Reload All Tabs in Current Safari Window
Once again, pretty much explained in the title. This script will reload every tab in the frontmost Safari Window:

tell application "Safari"
set this_win to (window 1)
repeat with j from 1 to the count of every tab in this_win
do JavaScript "window.location.reload()" in (tab j of window 1)
end repeat
end tell

Friday, April 3, 2009

Balance Out Your Headphones

If your headphones are louder in one ear than the other, it is possible to balance them out in System Preferences.

Step 1: Open System Preferences.

Step 2: Go to the Sound preferences.



Step 3: Plug in your headphones. (Recent Macs differentiate between when your headphones are plugged in and when they are not.)

Step 4: Click over to the "Output" section.

Step 5: In the middle of the window there will be a "Balance" slider. Adjust the slider until the audio appears to be coming from the center of your head.

Thursday, April 2, 2009

Change Default Screenshot Name (Revisited)

Last week I posted of a way to change the way screenshots are named so that the number comes before the name. If you just want to change the prefix from its default "Picture", there is a terminal command for that:

defaults write com.apple.screencapture name [string]




Just copy and paste that into Terminal.app (/Applications/Utilities/Terminal.app) and change the "[string]" section to the name you desire.

Wednesday, April 1, 2009

Use Variables Where They Aren't Allowed in Automator

It is possible to use an Automator variable in places Automator doesn't allow:

Step 1: Save the workflow.

Step 2: FInd the workflow in Finder.

Step 3: Right click on the workflow and select "Show Package Contents".

Step 4: Inside the "Contents" folder, there is a file called "document.wflow". Open that file in TextEdit as a plain text file.

Step 5: Search through the file for the name of your variable. You should find something like this:

<key>UUID</key>
<string>8C42DC22-6794-42FA-94B7-1A4144DDD596</string>
<key>identifier</key>
<string>com.apple.Automator.Variable.Text</string>
<key>name</key>
<string>Variable Name</string>
<key>value</key>
<string>What you saved the variable as.</string>


Step 6: Copy the long string of text under the "UUID" key (see bold text above).

Step 7: In automator, when you want to use the variable, type in "$(", then the string from step 6, then ")".



The variable won't change in Automator, but, when you run the workflow, Automator will act as if you used the variable.

[Via]