(* Welcome. This ApplesScript program is designed to automatically run the APM Tuner X program (v1.0a2) (c) 2000-2001 Eiji Maekawa. APM Tuner X is a useful utility to make hard drives more (or less) noisy and/or power consuming. Unfortunately it seems to be maintained no longer, and has no direct AppleScript support. This short script allows you to control APM Tuner X via AppleScript and OS X Universal Access. It is suitable for Mac OS x 10.3 and later, and can be compiled as a Universal application. Assumptions: 1- You've copied the "APM Tuner X 1.0a2" folder into the Utilities folder. 2- You haven't changed any file names. 3- You have OS X 10.3 or later 4- You have turned on Universal Access, in the System preferences. If you haven't you'll be shown how to do it the first time you run the script. Install Save this script into a convenient location, e.g. ~Applications. It will work from anywhere though. The changes to the hard drive do not seem to remain after a reboot. To save you having to manually run the script, you may like to add it to your Login Items, in the Accounts section of System Preferences. Run Double-click to run. The hard drive parameter is set, and the program quits automatically. If the script is successful, or "APM Tuner X" can't be found the reult is logged is logged to the Console. Making changes The most likely change you may want is to increase or decrease the APM setting. Find the line "set apmSetting to 220", and replace the 220 with a number between 0 and 254 If you don't keep the application in Utiltiies or have renamed something, modify the variables completeAppPath, appName or appFolder. Acknowledgements My first applescript: thanks to Apple and the Applescript team, MacOSXhints.com and macscripters.com for inspiration and information. legal small print Copyright © 2006 GMcCloskey The software is free software and is licensed under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *) on run if UIscript_check() then setApmTunerX() end if end run on setApmTunerX() -- Application Location - assumes you've put the original folder in Applications/Utilities -- If you've renamed the folder or put it somewhere different, then correct the two lines below set appFolder to "APM Tuner X 1.0a2" set appName to "APM Tuner X.app" set completeAppPath to (path to utilities folder as Unicode text) & appFolder (* -- hard drive value, between 0 and 254 -- 0 resets the drive to vendor settings -- lower numbers make the drive more power efficient and quieter, but potentially slower -- higher numbers do the opposite -- some hard drives make a 'clunk' noise that can be resolved by setting to about 210 or above -- see http://www.macosxhints.com/article.php?story=20041014005324939 for a discussion *) set apmSetting to 220 tell application "Finder" activate if folder completeAppPath exists then (*two methods to open the app. if you are having trouble, uncomment the first 'open app...' and comment-out 'tell app...'. *) -- open application file (completeAppPath & ":" & appName) tell application "APM Tuner X" to activate tell application "System Events" tell process "APM Tuner X" tell slider 1 of window 1 to set value to apmSetting keystroke return tell menu bar 1 tell menu "APM Tuner X" click menu item "Quit APM Tuner X" end tell end tell end tell end tell do shell script "echo `date`' " & ": " & "APM Tuner X control script: v1.0 Changed APM parameter to " & apmSetting & ".' > /dev/console" else do shell script "echo `date`' " & ": " & "APM Tuner X control script: v1.0 Failed to find APM Tuner application." & "' > /dev/console" set the dialog_message to "The application can not be found, please edit the Applescript script." display dialog dialog_message buttons {"Ok"} ¬ default button 1 with icon 1 end if end tell end setApmTunerX -- following script from Apple, http://www.apple.com/applescript/uiscripting/01.html on UIscript_check() -- get the system version set the hexData to system attribute "sysv" set hexString to {} repeat 4 times set hexString to ((hexData mod 16) as string) & hexString set hexData to hexData div 16 end repeat set the OS_version to the hexString as string if the OS_version is less than "1030" then display dialog "This script requires the installation of " & ¬ "Mac OS X 10.3 or higher." buttons {"Cancel"} ¬ default button 1 with icon 2 end if -- check to see if assistive devices is enabled tell application "System Events" set UI_enabled to UI elements enabled end tell if UI_enabled is false then tell application "System Preferences" activate set current pane to ¬ pane "com.apple.preference.universalaccess" set the dialog_message to "This script utilizes " & ¬ "the built-in Graphic User Interface Scripting " & ¬ "architecture of Mac OS X " & ¬ "which is currently disabled." & return & return & ¬ "You can activate GUI Scripting by selecting the " & ¬ "checkbox ?Enable access for assistive devices? " & ¬ "in the Universal Access preference pane." display dialog dialog_message buttons {"Cancel"} ¬ default button 1 with icon 1 end tell else return true end if end UIscript_check