Sunday, July 31, 2011

Quantifying the Return on Investment Potential of Applescript


Many of the arguments for the adoption of workflow automation in general and AppleScript automation in particular might seem obvious. However, it is always nice to be objective and simply present established facts to support such claims, especially when you are attempting to convince those who control a budget that it is worth the investment.
As fortune would have it, in 1999 GISTICS, a research firm that investigates new technology adoption and the strategic role that third-party developers play in maximizing the payback of new technologies, created seven informative publications analyzing Apple's technology. One of them was titled "AppleScript Payback Assessment — Return-on-investment Calculations for the Deployment of AppleScript by Smart Media Producers". Although it is now more than ten years old, this 54-page document highlights some very impressive results from using AppleScript to automate a workflow. I have derived most of the factual data I present here from that report.


Monetary Savings

Deploying AppleScript solutions can yield return on investment (ROI) figures anywhere from a typical five-fold annual ROI to an astonishing 24 times ROI realized in the first year of AppleScript deployment. In 1998, AppleScript produced an estimated $100,630,500 in total savings for North American media producer firms. One firm, after an investment of 500 hours developing a suite of scripts, derived $500,000 to $1.2 million in annual savings.

Improved Quality

When deploying AppleScript as a strategic platform by which to reengineer and systematize business processes for profit, executives and owners derive higher quality production at significantly lower costs and shorter production cycles. Scripts don't forget even the smallest rules they are "taught" and the attention to detail never fluctuates, no matter how tedious the task.

Increased Productivity

Simple tasks can be performed three to ten times faster by using AppleScript. For example, AppleScript can reduce complex tasks such as the composition of a catalog from a nine-person workweek to less than one hour.

Increased Workload and Profit

AppleScript creates more predictable workflows, enabling firms to accept larger jobs and faster cycle times.

Rapid Implementation

Compared to the time required to plan and develop solutions built with programming languages such as C++ or Visual Basic, AppleScript solutions can be built very quickly. Time-saving ideas can become part of your daily production process in a much shorter time frame and require less development and troubleshooting than other languages can offer.

Wednesday, July 27, 2011

Understanding the Scalability of Applescript

AppleScript is highly scalable in size and scope. Scripts can start out small, automating a single task with a few lines of code. Over time, they can grow into multifunctional tools and awesomely complex applications. They can also be designed to adapt as business rules and requirements change. Understanding some of the different form factors a script can take is beneficial knowledge to have.

Transition Scripts

transition script is a small script that provides a simple way to transition from one context to another. These scripts might only save a few seconds each time they are used, but over time those seconds add up.
An example of a transition script is a small script that enables users to quickly open a server folder of their choice. A button on a contact record in FileMaker Pro that uses a small script to locate and open a related folder is another. A text "cleaning" script might manipulate text in the clipboard in a variety of different ways, such as removing or adding hard returns, sorting the paragraphs, adding or removing prefixes or suffixes, or quickly saving the data into a text file in a folder the user chooses.
If a user forwards or replies to e-mail with standard responses or instructions, a simple script can automatically prepare the e-mail for review. Or if a selected file needs to be sent to a group of people, it can be dropped on a script that gives the user a choice of e-mail, FTP (File Transfer Protocol), or some other method of delivery and of a list of recipients.
Tip 
People often underestimate how much time is lost navigating around a server or typing out commonly used instructions into e-mail messages again and again. Small transition scripts can make a huge impact on a workflow, especially when they are used by a large number of people.

Script Tools

script tool is a script that performs some specific function or set of functions. While the size and scope of the automated task can vary dramatically and can evolve over time, a script tool is narrowly focused, much like the tools you use in your everyday life in the garage or kitchen. They are meant to be executed on users’ machines while they wait, setting them apart from fully autonomous solutions intended to run on a servers or dedicated computers.
Note 
Script tools are probably the most popular type of scripts built with AppleScript. They are relatively easy to design and develop and they have an immediate positive effect on the user's work. Simple tools can cross the line into transition scripts while more complex ones might blur the distinction between tools and full-blown solutions.
One of the best examples of a script tool is a batch processor script. Batch processor scripts perform a limited set of functions on any number of files. They might add layers, flatten or resize images, modify file names, generate reports, look for errors, convert file types, merge or parse PDF pages, and many more similar functions.
Script tools can do just about anything. Some might create a complex folder structure for a new project or help copy standard files into a new user directory. Others may help a user create a new product sheet from one of a group of available templates. Script tools can help search documents for text overflow errors or help users connect to servers in the morning. There really is no limit to the kinds of tools a thoughtful developer can dream up.

Script Solutions

script solution is made up of one or more scripts that automate highly complex and often lengthy processes. While the size and scope of solutions can vary like script tools, a script solution is more broadly focused on a larger sequence or quantity of tasks. While a script tool might help a user create a paragraph for a catalog page, or tabulate some data, a script solution can assemble an entire catalog file from start to finish. Besides the size of the scripts, the major distinction between a tool and a solution is that the latter is intended to run with minimal to no human intervention.
A script solution might start out small and gradually expand. In fact, many times a group of script tools can merge and evolve into a solution. As they become more complex and begin to control more steps of a workflow, script solutions can expand into a multi-module solution made up of dozens or hundreds of individual script files that are managed by a primary module that orchestrates a complex workflow.
The most common type of script solution is desktop publishing automation. For example, a script can perform multiple find, sort, and export routines to gather product information from a database that will be placed and styled in a page layout document. Next, the script can find image files on a server and import, size, and position them. Throughout this process, countless business and style rules are consistently applied. Product subcategories are automatically started on a new page or in a new document. Spacing is dynamically adjusted based on the amount of content for each product. Once the file has finished building, the script can save it for review or print it to a PDF file. It might also cross-reference products and price lists, and scan the document for text overflows or other issues and report them in a dialog box, text log, e-mail, or any other communication software. The same process can apply to any type of file, including brochures, flyers, reference guides, catalogs, and more.
Script solutions can take many other forms. Some might watch folders for files to process or instructions to carry out. Others might monitor file servers and report misplaced files to administrative personnel and performance issues to technical personnel. Others may merge photos into a time-lapse movie or contact sheet. Solutions can alert, analyze, build, create, compile, convert, delete, export, import, modify, or report just about anything.

Sunday, July 24, 2011

Defining Workflow Automation


Workflow automation is the creation of a technological solution to automatically perform some or all of the tasks within a given workflow. Although the focus here is on automating manual activity performed with software on a computer, the term applies to anything that increases the efficiency of the user. This includes everything from an electric pencil sharpener to programmable welding robots building car frames, or even to the computers used to control the International Space Station.
The personal computer itself is an example of workflow automation. Expanding on past tools such as calculators and slide rules, computers eliminate enormous amounts of manual work and save time. With spreadsheets, we no longer needed to punch numbers into a calculator and write them on paper. With word processors, we can make edits in a single document rather than having to type up an entirely new version to reflect changes. Countless other examples of automated workflows, such as steps in image processing and desktop publishing software, have lifted enormous burdens from our hands and have freed us to do more creative work. However, it doesn't just end there. The time you save today is invested in making possible the more advanced tools of tomorrow. Workflow automation is a continuing step in the process.

Busting Some Myths about Automation

Many of the myths about automation might seem a little dated today, but that alone won't quell them.

Automation Will Take My Job

In today's world of gadget-crazed consumers, it's hard to imagine that only a few decades ago there was a lot of computer phobia, especially when it came to discussing automation. Many people feared that computers would end up replacing humans while they watched Captain Kirk repeatedly make computers spontaneously self-destruct by presenting them with a logical paradox.
While any technological advance can displace and even eliminate certain jobs, in the long run, it often creates far more jobs than it replaces. For example, someone has to design, build, market, sell, program, and maintain the robots that autonomously weld car frames.
If you are asked to automate a task currently performed by people, being sensitive to how the change will be viewed is certainly a good idea. Sometimes a complex solution might displace a few jobs. However, the majority of the time automated solutions are just another tool that people will use to reduce the burden of mundane and repetitive work. Artists can spend more time on the creative aspects of their jobs when they are relived from saving hundreds of images in three different sizes and formats for a Web site. Page layout experts can focus on the unique aspects of a catalog rather than tediously copying and pasting thousand of product descriptions onto catalog pages.
Note 
It is important to remember that workflow automation with AppleScript is another way of making better tools and does not automatically mean that people will lose their jobs.

Automation Will Fix Our Problems

Perhaps the worst myth of all is that automation will fix problems. We should look to automation to amplify our strengths rather than to disguise our faults.
By itself, the act of automating a process does not guarantee an improvement to the process. While automation can magnify the efficiency of a process, it can also magnify any inefficiency that may exist. If business rules are not explicitly understood, documented, and communicated for a manual workflow, a workflow automation solution can inherit those flaws. If some of the steps required to carry out a certain task are forgotten or improperly embedded into scripts, the solution will not spontaneously correct those problems. This is one of the reasons why it is advisable to begin with smaller scripts and focus on familiar tasks, and then gradually take steps to advance to more complex situations.
The more removed you are from the end user, the more danger there is of someone assuming scripts can "just do things" without explicitly stating what those things are and the rules that guide them. If the end user has never performed the tasks manually, the danger of this myth increases exponentially. Be sure that everyone understands that while your scripts might seem magical, they aren't, and that you need clear details for even the smallest step in the process you are automating.
In the decades since the invention of the personal computer, we have witnessed amazing technological solutions to many problems that brought about many great benefits. But our relatively new "age of technology" is riddled with the corpses of horribly designed solutions. The majority of the time the fault lies in the belief that if we build it, it will "just work."

I Can Automate it and Forget it

The notion that you can build a complex piece of software that endures throughout time is another dangerous myth. Custom solutions must interact with various pieces of hardware, software, and business rules that inevitably change and, therefore, require monitoring, maintenance, upgrades, and enhancements over time. With every operating system or third-party application upgrade, a scripted solution needs to be retested and tweaked to ensure that it will continue performing as designed.
Certainly, a script can be left to run autonomously and will not require as much attention as a fully manual workflow. However, creating a script that creates a catalog file does not mean the catalog will be "perfect" and not require proofing. It uses data written by people and images processed, cropped, resized, and named by people. In some cases, the result of an automated task requires more proofing to ensure that the scripts are working correctly. However, that additional proofing time may be offset many times over by the enormous time saved during assembly.

Automation is Easy

Computers are so easy to use that they sometimes spoil us a little too much. Hidden from sight in the millions of lines of code is all of the effort needed to make them work well and keep our lives so carefree. The same is true of automation, which leads us to false conclusions that automated processes are easy to build.
Another culprit for the notion that writing scripts should be easy is our own brain. People are often amazed at the time involved to build a script that will automatically do things that they take for granted. Many of the mental tasks we perform so easily are very difficult to "teach" a computer. Deciding if a photo needs to be rotated or not is an instantaneous decision we make subconsciously. Picking a color to match a color scheme in a room is, at least for some, a simple task. However, these kinds of things are nearly impossible to program into a script.
Note 
To write a script, you need to know every detailed step in the process, including all the decision-making logic that users might take for granted.

Automation Will Make Us Appear Less Personal with Clients

The idea that automation shows or requires a lack of concern for personal interaction with clients or vendors is another common myth. Those who believe this fallacy have had too much exposure to poorly developed solutions. Everything from voice-mail systems that seem to be designed to keep us from every reaching a human being to cryptically formatted e-mails with "Do not reply" stamped in them makes some people leery of automating their interactions with their clients. However, these failures should be used as an inspirational call to arms.
Tip 
Any poorly implemented solution can certainly appear cold and impersonal. However, if done well, automated solutions can present you and your company as a technologically proficient and efficient vendor, which is always a plus. Most of the time, automated solutions can be completely concealed from view.
A piece of technology, by itself, isn't impersonal. It all depends on how you use it. When the telephone was first introduced, there were probably some who complained that it reduced face-to-face meetings. However, it also enabled people to "meet" more often. E-mail likely raised the same fears initially, but now it's clear how it has dramatically increased the amount of information we can quickly communicate.
Databases need to operate with a serial number assigned to each client. However, that doesn't mean you should forget your client's name and refer to the client only by the number.
Automation doesn't automatically turn a company into a cold, uncaring box. Instead, it makes possible a new level of personalized client communication. Product announcements can be created based on a client's individual profile, giving them a brochure specifically designed for them. Customized project status reports can be created to keep the client up to date and well informed about their project. Using a person's name in the Reply To address and taking care to format the data in a friendly, easy-to-read manner should just be common sense.

Exploring Reasons to Automate a Workflow

Automated solutions are, in a lot of ways, just like any other cost-saving policy a company might adopt. They can save time and reduce costs while increasing quality and capacity. However, unlike some new and oppressive rules and regulations dreamed up by "efficiency consultants," automation can achieve these goals while simultaneously reducing stress, improving morale, and allowing staff members to focus on more rewarding creative work rather than mundane, repetitive chores. In this way, well-designed workflow automation solutions can be mutually beneficial for both a company and its employees. Rather than viewing cost saving directives as punitive, employees and their company can use automation to obtain the same goals in a more rewarding way.

Improve Consistency

One of the first things to be affected when people are overworked is consistency. It is hard to step back and look at the big picture when you are crunching out a batch of files as quickly as possible. The thought of stopping just to remind yourself of a naming convention for Web site files or the correct column order for a sales report can be grueling when the clock winds down and you still have dozens of items on an urgent to do list.
An automated solution with all the company business logic correctly encoded within it applies those conventions every single time it executes, and does so dispassionately. Many human errors caused by fatigue, stress, or carelessness magically disappear.

Improve Quality

Automation can have a huge effect on quality. When a script frees employees from frantically working through lists of manual chores to meet a deadline, they can spend more of their time thinking about how they work and discovering new areas where automation might help improve their jobs. In short, they can focus on quality.
For example, if a script automatically assembles desktop publishing files, the layout designer can focus more attention on fine-tuning the master pages, style sheets, and artwork of the template. If a photographer doesn't have to manually save each photo in ten different sizes, each in a different file format and with a different naming convention, she is free to spend more time tweaking her photographs before sending them on to the next department.

Increase Project Size and Capacity

Automation also can make it possible to increase the size and capacity of projects. New services that are prohibitively labor intensive suddenly become a possibility. Because a computer can run constantly day and night, and on weekdays, weekends, and holidays, it can be continually building, processing, informing, and managing a variety of automated tasks from a massive queue in a folder. Massive tasks can be assigned to a fleet of automated servers, each responsible for one or more of a group of automated tasks.
Note 
When a script cuts the effort required for a particular project by some significant percentage, additional projects loaded onto the same staff are not as oppressive as they would be without automation.

Reduce Stress

Stress is a human response to adverse conditions. In business, people can experience elevated levels of stress when they have too much pending work, are too close to a deadline, or do not have the proper tools to complete the work. Under stress, people often begin to rush, cut corners, forget procedures, make typos, and worse.
The most common "solution" to such a situation is to reduce an employee's workload. Automation makes it possible to shift the focus to tools that allow the work to be completed more easily, creating less of a burden on an employee.
Scripts can help remind, encourage, and even autonomously enforce naming and other business conventions. They work tirelessly to perform routine tasks while the user is out to lunch, in a meeting, or at home for the evening. An inbox full of messages informing you that your documents have been successfully processed and are now waiting for your review is far more welcoming than strict and ominous reminders that you have work due.
Well-designed automated solutions can be a huge stress relief to every user involved in a given workflow.

Encourage Employee Innovation

Sometimes people hide in their cubicles, never making any suggestions for improvements because they don't want to create more work for themselves or others. Any suggestion for improvement to a company's products, services, or some part of their workflow often results in more work for someone, usually the one with the idea.
Workflow automation can have an opposite effect, making employees fountains of innovative ideas. Once users realize that automation creates tools that help them be more valuable employees while doing less manual work, their enthusiasm for innovation may be difficult to contain.

Wednesday, July 20, 2011

Workflow Automation with AppleScript

Before delving into the intricate details of designing, developing, and deploying AppleScript workflow solutions, take a step back and consider the various ways the solution might be used in the future. Such reflection will give you a much richer grasp of the benefits of AppleScript and what it can help you achieve.
workflow is an ordered sequence of individual steps that are performed together to achieve an overall task. Although the term can refer to any task, in this chapter, only tasks performed on a computer are relevant.
Before you can automate a workflow, you need to abstract the workflow steps from the other unrelated tasks with which they intersect. You must also delimit your focus to avoid being caught up in the folly of automating everything.
For example, suppose you were presented with the challenge of automating a catalog production workflow. At first it might sound easy. After all, there are only three or four steps. Material is created, placed into a page layout document, proofed, and then converted into a portable document format (PDF) file for print. However, each of these steps can be considered an entire workflow on its own. The text and images that eventually find their way into a page layout program might go through dozens of steps, from concept to completion, before getting to the page layout step. Further, some of the steps that occur during concept and completion might be defined as separate, smaller workflows. If you reduced the entire process down into the smallest individual steps, there might be thousands or millions of them.
When defining a workflow for eventual automation, it is important to focus on a reasonable portion of the "big picture" process. But you also need to choose processes that lend themselves to automation. Appropriate processes must have a lot of repetitive activity and not a great amount of creativity. Writing a script that places and styles text according to static business rules is a much more sensible choice for automation than trying to make a script perform the creative writing process necessary to generate the text in the first place.
Another factor to consider when searching for a workflow to automate is who performs the work manually. If your script will perform a handful of functions that you or your co-workers currently do manually, there isn't much to consider. However, some workflows might involve tasks performed by dozens of people. Those people might work for the same company or be diverse members of different companies, offices, departments, or disciplines. In such a case, you must consider the human factor as part of your definition of the workflow to ensure that you don't try to automate a workflow with a single script that must somehow pause and wait for people to perform a few steps. Instead, there should be multiple scripts, one for each discrete portion of the work. In essence, you want to automate tasks "between" people and not "through" them.
It can be a challenge to untangle a process from all the other processes and the people involved while simultaneously considering all the variables. Successful developers need to be able to alternate their focus from the isolated details of a process and the full context in which it exists. This skill is crucial for developers defining a workflow for automation.

Sunday, July 17, 2011

Respecting the Power of AppleScript


In the past, especially the early years of its genesis, AppleScript was often given a bad rap. Some would say it was only a script language, not a programming language. Others referred to it as buggy, slow, or weak. Some even predicted its obsolescence once Apple's OpenDoc technology emerged. Ironically, it was OpenDoc that was scraped in 1997.
Sometimes the criticism would come from programmers who promoted costly development in other languages, while other times, it came from developers or users who were "Windows centric" and looked down on the Mac and Apple. In this age of iPods, iPhones, and the witty "Mac versus PC" commercials, it may be difficult to believe this, but at the time, it was quite fashionable to predict doom and gloom for Apple and all of her wares, both hard and soft.
Admittedly, at least some of the criticism may have been earned, at least at first. There were bugs and speed issues in the early years, but the same was true of the Mac OS. lt relied a lot on third-party scriptable applications, which were slow to embrace it. But slowly, over time, the bugs were fixed, the computers became faster, and the scriptable applications began appearing everywhere. The language made the transition to the new and modern OS X and continued to evolve and to embrace new technologies.
AppleScript survived and, more importantly, it flourished. It won awards, was the focus of "return on investment" studies, and finally silenced the critics. Today a skillful developer can automate a large portion of a workflow, creating an unprecedented boom in efficiency.
It is finally time that AppleScript gets the respect it is due as a truly unique, powerful, and revolutionary technology that remains hard pressed to find an adequate rival on any platform. It is easy to learn, easy to use, and can do almost anything. It has been used to build countless catalogs, brochures, and factsheets. It has processed images, text, numbers, and more. It has been the workhorse of the computer age, doing the heavy lifting between applications, processes, and users. All indications show it will continue doing so for the foreseeable future.

Friday, July 15, 2011

Exploring the Uses and Users of AppleScript

As a flexible, inter-application scripting language, AppleScript has a virtually unlimited number of uses and can be used by every user of a Mac computer. Even though many users will not take the time to learn the language and write their own scripts, they can still use the scripts written by others.
Tip 
Always use caution when using scripts written by someone else. Be sure they are reputable or have a personal connection to you. A script could potentially perform malicious or virus-like behavior.
Scripts can react to various stimuli. Double-clicking a script application can begin an automated process while another application begins processing files a user drops on it. Scripts can be attached to the script menu, embedded into application menus and palettes, and on a Finder window toolbar. They can be launched by an iCal alarm or whenever files or folders appear in a watched folder. Scripts can talk to other scripts on a user's computer or other computers across the office or the Internet. Scripts can run day and night, constantly watching, checking, processing, and reporting on anything that anyone takes the time to develop.



Uses for AppleScript

While some scripts may possess wider appeal and mass-market usefulness, typically most focus on a specific company's unique workflow. They can integrate third-party applications in ways that would not be practical or economical for mass production. Every manual task performed on a Mac computer can be automated with AppleScript, leaving its limitations to that of your imagination.
The following examples provide a glimpse of the limitless activities that can be automated with AppleScript.

File Processing

There are numerous ways to streamline user interaction with files:
  • Image files can be opened, resized, flattened, modified with filters, and saved into one or more new files. A script can automatically create preview images for the Web and high-resolution files for print. It can make "decisions" and vary the processing tasks based on a characteristic of the file, such as the file name, layer names, size, or page orientation. Individual files can be merged into a preview sheet or split into separate files. Any of these tasks can be automatically performed on a folder of 10 images or 10,000.
  • PDF files can be manipulated with AppleScript to suit the needs of even the most complex workflow. Scripts can add or remove pages, stamps, comments, and more. Separate files can be merged into a single file while multiple page files can be split into individual files. A script can generate PDFs, print them, and place them in a folder for human review. The content of the files can be resumes, books, instruction manuals, fact sheets, and countless others. A script can detect and process each with a separate set of business logic.
  • Scripts can manipulate text-based data files of any type. They can change delimiters to comma, tab, or fixed width text. They can extract specific rows or columns based on date ranges, product numbers, or customer name and then generate a new file with only the desired information. The files can be resorted, have data added or removed, and can be checked for common errors. Characters can be replaced with other characters to conform to importing regulations of databases, hypertext markup language (HTML) language rules or your company business rules.

E-Mail Processing

On an automated e-mail account or a user's computer, AppleScript can help manage a crowded inbox and assist in sending bulk e-mail:
  • Scripts can scan, read, and take predetermined actions on incoming messages in many popular e-mail applications. They can also help you prepare, create, and customize messages to a batch of contacts.
  • Scripts can detect, read, parse, and route data from a Web form to a database. On a user's computer, this can be done with a mail rule that runs an AppleScript when Mail detects a web form email. A server with a fully autonomous script and dedicated e-mail account can constantly monitor the inbox for various messages from different Web forms. Once an incoming message has been processed, an alert can be sent to key personnel notifying them of the new information.
  • Scripts can help send e-mail, especially in batches. Sending a single e-mail message to a huge list can be less impersonal by a script that sends a separate e-mail to each person on a list with a personalized greeting. Scripts can even build a unique e-mail based on customer ordering patterns, available material, and encoded business rules that describe how the recipient and the personal message should be matched up.

Desktop Publishing Automation

Using scripts to automate laborious desktop publishing tasks could fill endless volumes. Scripts can build simple pages with a variety of styles or build complex pages with hundreds or thousands of specific business rules encoded. They can build catalogs, complex tables, and charts, and automatically import text and images from various sources. They do all of this while reducing errors, improving consistency, and flawlessly enforcing style guidelines. In addition:
  • Scripts can build catalog files of any type. Even a catalog with uniform styling and formatting can be a burdensome task to build by hand. A user must copy, paste, position, and style text, then search for and import the appropriate artwork or images. When catalog pages vary by category or product data, scripts eliminate the need to remember numerous layout design rules. They can quickly and accurately locate the text and images necessary to build richly styled and dynamically spaced product information into a copy of the appropriate template. Watching for changes in category or other group fields, a script can diverge the styles and structure based on the appropriate rules. For example, each product category could require the insertion of a title page with a leading blank page or it might prompt the creation of an entire new document for each section.
  • Scripts can scan documents and build indexes or tables of contents. They can cross-reference products across corresponding documents, such as a catalog that has a separate price book.
Some processes are too daunting to contemplate without scripts, such as modifying hundreds of price changes or adding or removing products. Instead of manually updating pricing and squeezing new products into spaces left by old ones, a script enables you to simply build an entirely new catalog.
Monitoring sales performance of a catalog or other advertisement can be difficult when simply looking at the numbers. The context of the sale — such as the page the customer was reading when ordering — can be just as important to determine which strategies are working and which are not. A script can open documents, color-code product information based on actual sales, expand the page size, and integrate key sales data right on the page. Imagine the advantage of not just knowing how well a product did but also why it did so well when placed in a certain location on a page.

Central Processing and Resource Monitoring

Even as a script saves you time, it might be wasting it. Rather than sitting idle, mesmerized as you watch a script take control of the applications on your computer, you might consider setting up an automation server. Just as a file server, mail server, or Web server centrally processes information for its respective services, an automation server is a shared computer on a network that centrally processes all of your automated activity.
Tip 
A Windows-based company can still benefit from AppleScript automation with a single Mac acting as an automation server. All of the scripts process incoming files and then push them back out to the users. This can even be a great way to help convince management to consider a full switch to Mac OS X.
Instructions can be sent to an automation server is many different ways. The most common is to simply move files for processing into folders that are being watched by a script. When a new file appears, the script "wakes up" and begins processing them. Likewise, users might indicate through a database or a small custom script which catalog they want to build. The script would receive these instructions and begin the process. With an automation server watching folders, multiple users can send files dozens or hundreds of files at the same time. They are queued up in the watched folder and are processed while users work on other tasks, go to lunch, or leave for the day. The scripts keep on working.
Scripts that monitor valuable resources and ensure that key systems are up and running are best suited when they are running on an automation server. For example:
  • Scripts can search, sort, and extract data from databases and then create and send periodic e-mail reports to key personnel. A script can send a daily sales report, tabulated survey data, a summary of sales leads, and any other kind of report you can generate manually. This saves users the time it takes to locate, open, and create a report query, and a report can even be generated early in the morning before the staff arrives.
  • A script can scan a file server to ensure that folder structure rules are being followed. If misfiled items are detected, it might send an e-mail alert listing the offending items and can even include a URL link so the reader can quickly navigate to the item to remedy the situation. It might send one e-mail to graphic artists informing them that images are supposed to be in a subfolder called Product Images and another to the sales team indicating that spreadsheets need to be in the Reports folder. Managers can be CC'd on these, notifying them of issues and empowering them when they need to enforce compliance.

Users of AppleScript

While the AppleScript language is designed to be accessible for casual programmers of varying skill level to write scripts, it can be used by anyone. Scripts built with AppleScript can dramatically increase a user's productivity while simultaneously reducing stress and errors and increasing adherence to business rules Scripts free up users to focus on details that cannot be automated and require human attention.

Individuals

Whether an employee works for a small, family-owned business or a Fortune 500 corporation, he can use AppleScript solutions to streamline any repetitive task. Any task, large or small, involving at least some repetition can typically benefit from automation. These custom tools can be built to help remind, assist, and notify this employee with his daily work.

Teams

As part of a team, individuals need to focus not only on their work but also keep in mind how their work integrates with their co-workers and the goals of the team. When each member of the group has access to a well-designed set of tools that helps her get her work done quickly while adhering to company policy, the team will benefit enormously. Scripts can help team members navigate project folders; store files in the correct location, with approved naming conventions; and notify others about their status. Scripts can remove much of the stressful and redundant tasks that can sap the creative effort a team needs to thrive. An overworked team might rejoice over more work as long as they have the tools necessary to get it done.

Companies

The breadth of a scripted solution has no limitations. As long as it is worth the development effort required, automation can provide solutions to individuals, teams, divisions, and more. Any and every department within a company can benefit by automation. Whether it is sales, marketing, design, inventory, shipping, or any other department, AppleScript provides a powerfully scalable technology that can be a solution to almost every repetitive problem you can imagine, regardless of the industry. Scripts enable companies to improve the quality and quantity of work while reducing costs, errors, and stress, leaving in their wake an environment conducive to creative thought.

Sunday, July 10, 2011

Understanding the Unique Characteristics of AppleScript


While old-fashioned macro recording utilities were quite useful in their time — they could simulate a series of literal keystrokes and mouse clicks, respectively — it was difficult to use them in a dynamic and practical manner. With AppleScript you can not only automate a sequence of literal actions, but also you can create a dynamic script that includes logical branches, variable content, and options for different behavior depending on specific conditions. This gives AppleScript the power of a real programming language.
AppleScript possesses more unique characteristics that add to its appeal, such as its English-like syntax, the fact that it is universally open-ended, its deep level of access into the Mac OS framework and the frameworks of third-party applications, and its consistency between OS updates.

English-Like Syntax

One of the most unique characteristics of AppleScript is its English-like syntax. While some detractors might say it is not even close to "natural spoken English," most would agree that it is certainly more like a spoken language than most other scripting and programming languages. The difference in syntax can be illustrated with a few simple examples.
The following examples present a sort of Rosetta Stone of programming languages. The code in each example performs exactly the same function: It builds a text-based list of numbers within a range specified by two variables. At the end of each script, the resulting value will be a sequence of numbers from 25 to 30 with a carriage return after each number.
Listing 1 illustrates the English-like language used in AppleScript. Notice how setting the content of a variable doesn't require any code-like declarations or explicit identification of the initial value's data class. Also, there is no need to worry about line endings; just type a return and keep on typing.
Listing 1: AppleScript

set numLength to 5
set numStart to 25
set textResults to numStart as string
if numLength > 1 then
    repeat with a from 1 to numLength
        set numStart to numStart + 1
        set textResults to textResults & return & numStart
    end repeat
end if

The code script shown in Listing 2 performs the same functions with JavaScript. Putting a value into a variable is a little less English-like. Like many other languages, JavaScript requires a special line ending, which in this case is a semi-colon. Also, the repeat loop is more cryptically phrased and, therefore, less clear than the AppleScript example.
Listing 2: JavaScript

var numLength = 5;
var numStart = 25;
var textResults = numStart;
for (var a=numStart+1; a<=(numStart+numLength); a++) {
     textResults=textResults + '<br>' + a;
}

The code in Listing 3 performs the same functions using the REALBasic language. Notice that the variable declarations are more complicated and require the data class of each must be specifically stated prior to placing a value within them.
Listing 3: REALBasic


Dim numLength as Integer
Dim numStart as Integer
Dim textResults as String
Dim a as Integer
numLength = 5
numStart = 25
textResults= str(numStart)
if numLength > 1 then
  For a=1 to numLength
    numStart=numStart+1
    textResults = textResults + Chr(13) + str(numStart)
  Next
end if

Finally, the code shown in Listing 4 performs the same functions with PHP (Hypertext Preprocessor). Like JavaScript, it requires line endings and brackets enclosing a more cryptic combination if-then and repeat function.
Listing 4: PHP

$numLength = 5;
$numStart = 25;
$textResults = $numStart; //no coercion is necessary
if ($numLength > 1) {
for ($a = $numStart+1; $a <= ($numStart + $numLength); $a++) {
   $textResults = $textResults . "<br>\n". $a;
}
}

Certainly, the development time required to build a script always depends on the complexity of the tasks to be automated. However, AppleScript's English-like language and automatic handling of many fundamental programming chores significantly reduce the time required to develop a solution.


Universally Open-Ended

Another important characteristic of AppleScript is its success as an open-ended, universal scripting language. Before AppleScript, the few applications that enabled users to automate tasks each had their own way of doing things. In today's modern Internet-driven world full of standard languages, it is hard to imagine a time when each application had its own set of rules. Imagine a nightmarish world in which every Web site had its own language and, therefore, its own browser. Perhaps that is a bit dramatic, but that is not totally unlike the way things were with automation.
In a world without AppleScript, each application would need its own macro language and features. To use them, you would have to learn and remember each of them from any number of applications. Creating a macro that works across multiple applications would be difficult to virtually impossible. Some software might try to bridge this gap, but it could break with each OS upgrade and generally would be more trouble than it's worth.
AppleScript addresses such nightmares by implementing a universal language with which any and all applications could communicate. An application possesses its own object model that can be automated by AppleScript, specifying the objects, properties, and commands that it can work with. In a way, each application's script dictionary becomes an extension of the AppleScript language, offering its unique services to a script in a familiar way.
Today, virtually every application developed for the Mac has some scriptable features. Widely used applications like Adobe's Creative Suite have extensive support for automating almost every conceivable feature. For those applications that don't support scripting, or to access a command not made accessible to AppleScript, Apple developed System Events. This amazing scripting addition enables AppleScript to simulate mouse clicks, keystrokes, and menu selections in many un-scriptable applications, thereby allowing you to script the un-scriptable.

Deep Level of Access

AppleScript enables scripts to tap into many of the technologies of Mac OS X with its unique ease of use. For example, the do shell script command in the Standard Scripting Additions enables a script to run any shell script.
AppleScript also has access to many of the frameworks created by Apple for their applications and for third-party developers. These are made available to scripts with Scripting Additions. The Image Events scripting addition enables scripts to access the Core Image framework of the OS. Also, soon after the Core Data framework was developed, the Database Events scripting addition became available.

Consistency Maintained between Updates

Because AppleScript is built as a clean and easy-to-use layer on top of the OS that obscures the complex connection to the lower-level architecture, scripts typically continue to work from one OS update to the next. While major OS changes typically require bug fixes or complete overhauls of third-party applications, scripts are usually immune to such things. Even the transition from the "Classic" OS (System 9) to Mac OS X didn't require much more than a recompiling and resaving of older scripts.
When third-party applications require major rewrites or make changes to their object model and command libraries, it can break scripts. However, most applications eventually maintain a relatively consistent language for objects, their properties, and the commands they support.