Archive for March, 2008

Mar 31 2008

ScreenSteps - Part 2

Published by john under Tools/Utilities

Revisiting where I left off in ScreenSteps Part 1, I had an interest to try the export to blog feature, for obvious reasons. When you chose to export to a blog, the content you create in ScreenSteps is uploaded to ScreenStepsLive, a hosting service specifically created for ScreenStep applications. Once the application content is uploaded, a block of HTML is generated, which you can then copy into a blog.

In order to make all this happen you need to create a ScreenStepsLive account, which ranges from free up to $149 per month, with the variations being number of users who can post lessons, storage space limitations, etc.

To see how the content would look when posting to this blog, I generated a ScreenSteps lesson, created an account on ScreenStepsLive and exported to each of the supported formats. The results are all shown below:


 

 

MacDeveloperTips Email Subscription

Step by step process to subscribe by email to MacDeveloperTips.com

 

Step 1 - Browse to MacDeveloperTips.com

 

Step 2 - Click on the ‘Tips by Email’ option

 

Step 3- Enter your email address and verification message and click Complete Subscription Request

 

Step 4 - Check your email for a subscription request confirmation

Click on the link in the confirmation email and you’re good to go!


As far as ease of use, I will say the copy/paste approach for use within a blog couldn’t be much easier, and I anticipate that the options for noodling with the content layout will continue to evolve with new releases of the software. ScreenSteps is an intriguing application for creating visual step-by-step guides.

Give it a try next time you are called upon from your non-techie friends or family for computer support :)

Technorati Tags:

No responses yet

Mar 28 2008

Copy Finder Path to Clipboard - Tip 2

Published by john under AppleScript, System, Tools/Utilities

Yesterday I wrote a short AppleScript application that copied the current path of the Finder window to the clipboard. A rather unassuming, yet handy application. One downside to this application is that if you want the path of a folder selected in Finder, you would have to double-click on the folder to change the Finder path to that folder location, and then you could engage the AppleSscript application to copy the path.

For example, in the figure below clicking the Script Editor icon that we created in yesterday’s post (to the right of the terminal window with green arrow) will copy the path /Applications/ to the clipboard. However, what if you intention was to copy the path of the highlighted folder, that is, /Applications/Utilities/Java/ ?

I’ve reworked the original example to add support for dragging a folder onto the icon and also moved the code for displaying a dialog box when an error occurs into a subroutine. Take a look at updated application below:

Script Editor Click here to paste the code below into the Script Editor

-- When clicking on the icon
try
  tell application "Finder"
    set currentPath to (POSIX path of (target of front window as alias))
    set the clipboard to currentPath
  end tell
on error
  my finderErrorMsg()
end try

-- When dropping a folder onto the icon
on open {droppedFolder}
  try
    tell application "Finder"
      set the currentPath to (POSIX path of droppedFolder as text)
      set the clipboard to currentPath
    end tell
  on error
    my finderErrorMsg
  end try
end open

-- Error msg when unable to copy a path to the clipboard
on finderErrorMsg()
  display dialog "Unable to copy a path to the clipboard.
                      Make sure Finder is referencing a directory/folder
                      within the file system."
                      buttons {"Ok"} with icon caution with title "Error"
end finderErrorMsg

With the addition of the on open reference (line 12) you can now drag/drop a folder in Finder onto the application icon and its path will be copied to the clipboard. Before you can use the script, you will need to save the AppleScript code as an application and drag the script onto the toolbar (remove any previous version of the program by right clicking and selecting ‘Remove Item’).

As a quick debugging tip, you can add a dialog box as shown below to display the path that was copied into the clipboard:

tell application "Finder"
  set currentPath to (POSIX path of (target of front window as text))
  set the clipboard to currentPath
  display dialog currentPath buttons {"ok"}
end tell
...

Now you can view the clipboard contents (through the dialog box) which makes the debugging process a little easier should you decide to tweak this application.

Another good example of the power of scripting on a Mac.

Technorati Tags: ,

No responses yet

Mar 27 2008

Copy Finder Path to Clipboard - Tip 1

Published by john under AppleScript, System, Tools/Utilities

I’ve written a short script that I’ve found more useful that I ever anticipated. It is nothing more than an AppleScript application that copies the current path of Finder to the clipboard. Sounds rather unassuming, however, I think you’ll be surprised how handy it is.

The AppleScript code is less than 10 lines that instruct Finder to get the path of the front most Finder window and copy the path to the clipboard.

Script Editor Click here to paste the code below into the Script Editor

try
  tell application "Finder"
    set currentPath to (POSIX path of (target of front window as alias))
    set the clipboard to currentPath
  end tell
on error
  display dialog "Unable to copy a path to the clipboard.
                      Make sure Finder is referencing a directory/folder
                      within the file system."
                      buttons {"Ok"} with icon caution with title "Error"
end try

From within Script Editor, save the code as an application and then drag/drop the application to the toolbar in Finder. The screenshot below shows the Script Editor icon in Finder (to the right of the terminal window with the green arrow), where it is now one click away.

There is a trivial amount of error handling in this short script. If you try and run this script while Finder is referencing the system (as compared to a directory/folder on the system) you’ll get the following error message.

In the next tip of this series we’ll drill down one level further and I’ll show how to copy the path of a selected folder within the current Finder window, to the clipboard.

Technorati Tags: ,

2 responses so far

Mar 25 2008

Open Terminal Here…

Published by john under System, Tools/Utilities

I can’t count how many times I’ve found myself in Finder and wanted to jump to a terminal at the current path location. The Open Terminal application is one of those little gems that will make you wonder how you ever got along without it. If you spend any time at all moving between Finder and a terminal, read on…

Installing the application is as simple as extracting the zip file and dragging the OpenTerminal.app file into a location where you store other scripts, tools, utilities, etc. I have a folder within my home directory where I dump all this kind of stuff, so down the road when I bump into this folder I’ll have a clue where the applications came from.

With the app installed, open Finder and drag the application to the toolbar. You’ll see the icon appear as shown here:

The first time you run this application you will be presented will an impressive list of options. The defaults work fine, however, take a few minutes to read through each option. Depending on how you work, chances are you can configure this app to keep pace with you.

Clicking on the Shell config option (on the top left) will present even more configurations choices:

If you are not using the default shell on Mac OS X (bash) I recommend choosing the ‘pushd’ option as this is another really handy tool to have when bouncing around the file system (pushd/popd are built-in commands on bash).

From here forward, whenever you are in Finder and want to jump to a terminal, simply click on the Open Terminal icon, and you’ll be whisked off to a terminal window. Slick.

The latest version will only work on Leopard, however, you can download an older version for Tiger as well. The only downside to this application is that the source code is not included. I’ll keep my eyes peeled for a similar version that includes the source. If you find one first, please post a comment.

Now if only the terminal was available through a right-click in Finder…

Technorati Tags: ,

3 responses so far

Mar 25 2008

Ruby as AppleScript Alternative - Part 6

Published by john under Ruby

In this post I’ll show how to use the interactive help system within rb-appscript to explore the scripting interface for an application. To begin, you’ll need to verify that you have installed ASDictionary version 0.9.0 or later. You can download ASDictionary from here.

I would recommend you verify the path to the Ruby interpreter within the ASDictionary preference settings. To determine the location of the Ruby interpreter on your system, enter which ruby in a terminal:

Copy the path (where Ruby is located on your system) into the Preferences dialog for ASDictionary as shown below. That should do it for configuration.

The best way to understand how the interactive help works is to go through an example. So, let’s say that you are interested to get the name of every item in the Documents folder…begin by starting the Ruby interactive interpreter , following by the necessary require/include statements (see below) and creating a reference to the Finder application. From Finder, we can make our first request for help, by invoking Finder.help:

Notice there is a property (highlighted above) for a home property, which provides a shortcut to the user’s Home folder. Taking this one step further, let’s request additional help entering Finder.home.help:

Under the list of Elements, notice the reference to folders, which indicates that a folder object has a one-to-many relationship with the file system objects it contains. Using this information, you could now access all the sub-folders of the home folder using the folders element.

Appscript uses the #[] method to specify elements by name, so to get the Documents folder of the Home folder you could use: finder.home.folders[’Documents’]. Referring again to the help information, we know that we can get the contents (items) of a folder using the items element. Using items will identify all of the folder’s contents. Notice the other options such as files, alias_files, application_files, etc that we can use to identify only certain types of items within a folder.

We can further drill down with the help system to get more information about the items within a folder using finder.home.folders[’Documents’].items.help, as shown below:

Notice we can now access an items name, extension, among other properties. We began with the intention to get the name of every item in the Document folders, and with the last help statement, we now have all the information we need. The full rb-appscript statement looks like this: finder.home.folders[’Documents’].items.name.get

You can read more about the help system in the rb-appscript manual.

Additional posts in the series: Part 1, Part 2, Part 3, Part 4, Part 5

Technorati Tags: ,

3 responses so far

Mar 24 2008

Ruby as AppleScript Alternative - Part 5

Published by john under Ruby

In the previous posts on rb-appscript I dug into some code to show how you can use Ruby and rb-appscript to accomplish the same tasks available with AppleScript. Let’s take a few steps back to look closer at some of the workings behind AppleScript, which is important to understand if you want to begin any serious work regardless of the scripting language you choose.

The Open Scripting Architecture (OSA) is designed to allow for automating tasks, inter-application communication and otherwise directing application behavior. Apple events are the backbone of OSA, facilitating messaging and interaction with applications (think interprocess communication).
Continue reading...

Technorati Tags: ,

No responses yet

Mar 21 2008

ScreenSteps - Part 1

Published by john under Tools/Utilities

One aspect of my day job is developer relations for Mojax, an application framework for building mobile applications. Screencasts have been helpful to demonstrate various aspects of the platform and tools.

I currently use iShowU for creating screencasts. This is a great little tool and has pretty much covered all our needs. However, creating screencasts is time consuming, to say the least. In an effort to find something that we can use to crank out step-by-step tutorials in short order, Rodney Aiglstorfer, CTO of Mojax (mFoundry), suggested I give ScreenSteps a look.

Continue reading...

Technorati Tags:

No responses yet

Next »