Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Move and resize app windows via AppleScript System
I'm a neatness freak, and I hate lots of messy overlapping windows everywhere. But I'm also a keyboard junkie, and I hate using the trackpad a lot. And I don't want anymore background processes hogging memory, or more applications to open for such a simple task -- so what to do? Answer: AppleScript. I wrote a collection of AppleScripts that use System Events to control the window size and position of the frontmost application. Also, the window snaps to a grid to make it easy to place next to other windows without overlapping.

You can find the scripts on my iDisk public folder (Go » iDisk » Other User's Public Folder, then enter phildooher). Download the zip file and put the (nine) scripts in your usual script folder. The scripts are known to work on OS X 10.4.11, but are untested on 10.5. [robg adds: I tested a few of these, but not all, on 10.5, and they seem to work as described.]

Assign keyboard shortcuts to these scripts (using Quicksilver or your other favorite tool), and you can move and resize many application windows without using the mouse. Also, there is a 'Finder window 1 remember position' script to stop those pesky Finder windows wandering about after closing. These scripts work in many apps, including at least these: Finder, Safari, Mail, Firefox, TextEdit, Script Editor, Preview, OpenOffice Aqua, Skype, and many others. They don'e seem to work in iTunes, NeoOffice (window 1 resizes, but no scroll bars), and Word 2004. Apps that require specific window sizes, or have floating windows, can be uncooperative. QuickTime Player usually resizes windows proportionally, so video playback might fit to the window instead of being the correct aspect ratio. There is more info on how the scripts work inside the scripts (especially the 'Frontmost application window snap to grid move left' script).
read more (348 words)   Post a comment  •  Comments (13)  
  • Currently 2.55 / 5
  You rated: 3 / 5 (11 votes cast)
 
[41,397 views] Email Article To a Friend View Printable Version
Temporarily suspend energy saver settings via script System
When watching videos in QuickTime Player and DVD Player, the screen saver and energy saver are automatically suspended, but not so if you're watching full-screen Flash video -- using the BBC iPlayer, for example. This AppleScript takes care of that problem:
(*
    Suspend Energy Saver © RickoKid 2008
    Version 0.1
  
    TODO: Change so that authentication only has to be given once for non-administrator users, no matter how long suspension is in place.

  
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program 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.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*)

set userPass to ""
set battState to {powersource:"Battery", sleep:"", displaysleep:""}
set acState to {powersource:"AC Power", sleep:"", displaysleep:""}

if (do shell script "id -Gn") contains " admin" then
  (*  If user is admin, ask for password.  Otherwise, leave it to the system
    to ask username and password of an administrator (which will
    probably time out and ask again when ending suspension.  *)
  
  display dialog "Please type your password" default answer "" default button "OK" with hidden answer
  set userPass to text returned of the result
end if

set pmState to (do shell script "pmset -g disk") -->  Get current settings for both Battery and AC Power, and Screen Saver timeout. 
set saverState to (do shell script "defaults -currentHost read com.apple.screensaver idleTime") as number
repeat with stateSetting in paragraphs of pmState
  if stateSetting contains "Battery" then --> write following values to the battState record
    set powersource to (a reference to battState)
  else if stateSetting contains "AC Power" then --> write following values to the acState record
    set powersource to (a reference to acState)
  else if stateSetting contains " sleep" then
    set sleep of powersource to (word 2 of stateSetting)
  else if stateSetting contains " displaysleep" then
    set displaysleep of powersource to (word 2 of stateSetting)
  end if
end repeat

-->  Disable sleep, displaysleep and screen saver for both Battery and AC Power
if userPass is not "" then (do shell script "pwd" password userPass with administrator privileges) --> If we have a admin password, activate it.
set battSleepResult to (do shell script "pmset -b sleep 0" with administrator privileges and password)
set battdisplayResult to (do shell script "pmset -b displaysleep 0" with administrator privileges and password)
set acSleepResult to (do shell script "pmset -c sleep 0" with administrator privileges and password)
set acdisplayResult to (do shell script "pmset -c displaysleep 0" with administrator privileges and password)
set ssResult to (do shell script "defaults -currentHost write com.apple.screensaver idleTime 0")

display dialog 
  "Sleep and Screensaver are now temporarily suspended." with title 
  "Energy Saver Suspended" buttons {"Resume"} default button "Resume" with icon 1

-->  Re-enable sleep, displaysleep and screen saver for both Battery and AC Power, by restoring the saved settings.
if userPass is not "" then (do shell script "pwd" password userPass with administrator privileges) --> If we have a admin password, activate it.
set battSleepResult to (do shell script "pmset -b sleep " & sleep of battState with administrator privileges and password)
set battdisplayResult to (do shell script "pmset -b displaysleep " & displaysleep of battState with administrator privileges and password)
set acSleepResult to (do shell script "pmset -c sleep " & sleep of acState with administrator privileges and password)
set acdisplayResult to (do shell script "pmset -c displaysleep " & displaysleep of acState with administrator privileges and password)
set ssResult to (do shell script "defaults -currentHost write com.apple.screensaver idleTime " & saverState)
The above script will temporarily suspend the Energy Saver and screen saver until you click the Resume button. If you're logged in as an administrator, you'll need to provide your password first. (The original version of this script can be found in this post on my site.)

[robg adds: I haven't tested this one...]
  Post a comment  •  Comments (8)  
  • Currently 1.25 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[12,778 views] Email Article To a Friend View Printable Version
Learn more with free Apple seminars and tutorials System
Apple hosts free seminars and tutorials on a variety of topics -- both in-person at Apple Stores (at least in the USA) and online. You can find in-person events using this page, which has a number of search options. If you'd like to just see the online tutorials, try this page. Simply create an account (i.e. provide email and password) to register for the seminar/event -- you'll get an email with a link to the seminar/event.

There are topics covering everything from podcasting to GarageBand to Motion, switching to the Mac from Windows, Windows compatibility, and much more -- check out the lists at the above links.

[robg adds: Not a direct hint per se, but given I'd never seen either of these pages, I thought they might be worth sharing. There are some good tutorials available, at least in the online realm. I sampled the Motion tutorial, and it's very well done, as you might expect of Apple. The only major complaint I have is that the tutorials are streaming videos, not downloadable QuickTime movies, so you can only watch them when you have a net connection. It'd be nice to have a local library of the tutorials for offline reference as well.]
  Post a comment  •  Comments (2)  
  • Currently 2.14 / 5
  You rated: 3 / 5 (7 votes cast)
 
[6,670 views] Email Article To a Friend View Printable Version
Solve a problem where Docked items move or vanish System
I use SyncTogether to keep my iMac and MacBook (both Leopard) in sync. I usually sync iCal, Address Book, bookmarks, notes and Dock items. Several days ago, however, I started to notice a very annoying issue with my iMac's Dock: some items started to move around on the Dock, or completely disappeared from it. Even if I placed the vanished items back on the Dock and selected Keep in Dock, they vanished after a while.

I can't remember what was I doing when it started, but yesterday, the problem replicated itself to the MacBook. Other accounts were working normally, but not mine. I deleted the com.apple.dock.* files, but nothing changed. After using fsevent for a while, I noted some recent activities in ~/Library » Application Support » SyncServices » Local.

I decided to make a backup of that whole directory, and in a brute force way, I then deleted the content of the clientdata and DataReferences folders within that directory. After setting up my Docks again on both machines, everything has remained in place -- so far, the Dock is working perfectly on both Macs.

I'm not positive if this is related to SyncTogether, but I mention it because the solution was related to syncing. I think I synced Preferences, too, one time not so long ago, so maybe that was the origin of all these problems. In any event, I hope this helps someone who may be having the same issues.
  Post a comment  •  Comments (4)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[5,838 views] Email Article To a Friend View Printable Version
Work in some windows while Dashboard is active System
I use a small utility called Witch to switch between open windows in applications via Option-Tab, instead of using the built-in Command-Tab, which just switches between applications. I recently realized that, when Dashboard is active (F12), you can use Witch (Option-Tab) to select a window, and then you can do some things in this window while still having Dashboard active and frontmost.

For example, you can select a TextEdit window and write in it, jotting down some notes relative to something in a Dashboard widget. This will work as long as you don't click the mouse button. I've found this quite useful at times.

[robg adds: This could also be useful for selecting text in a background window and copying it (hold down Shift and use the arrow keys to select text, then press Command-C), for pasting into a Dashboard widget, if you forgot to copy it before you invoked Dashboard.]
  Post a comment  •  Comments (7)  
  • Currently 1.20 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[5,547 views] Email Article To a Friend View Printable Version
Erase free disk space from the command line System
It is possible to use Disk Utility to erase the free space on a disk. However, I had difficulty finding a command, such as hdiutil, to do it from the command line. One advantage of doing it from the command line is that it is easier to use cron or launchd to automate the process.

It turns out the solution is relatively straightforward:
cat /dev/zero > /private/tmp/junk; rm /private/tmp/junk
The first part of the command will keep enlarging a file with zeros until disk space runs out. After an error, the second part will delete the empty file. Lather, rinse, repeat for extra security (7-pass, 35-pass Guttman).

[robg adds: I haven't tested this one...however, I'd be somewhat cautious about using it on your boot drive. Running out of space on the boot drive -- even briefly -- may cause issues. If you know more about that possibility than I do, please comment!]
  Post a comment  •  Comments (18)  
  • Currently 2.25 / 5
  You rated: 2 / 5 (12 votes cast)
 
[26,315 views] Email Article To a Friend View Printable Version
Use launchd to replace folder actions System
Folder actions are quite slow, and on 10.5.x, I found them to be not really fun to play with. Another way to watch a folder is to create your own launchd script. Here's one as an example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>com.domain.whatever</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Library/Scripts/domain/whatever.sh</string>
    </array>
    <key>QueueDirectories</key>
    <array>
        <string>/Volumes/hd/any/path/to/a/folder</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>onDemand</key>
    <true/>
</dict>
</plist>
In the above, whatever.sh calls an AppleScript that automatically does something with newly arrived files (OCR, picture conversion, etc.):
#!/bin/bash
osascript /Library/Scripts/domain/whatever.scpt
This works fine, but you may find entries like this in you logs, repeated every 10 seconds:
01.04.08 10:54:17 com.apple.launchd[146] (com.domain.whatever) Throttling respawn: Will start in 9 seconds
01.04.08 10:54:28 com.apple.launchd[146] (com.domain.whatever) Throttling respawn: Will start in 8 seconds
01.04.08 10:54:38 com.apple.launchd[146] (com.domain.whatever) Throttling respawn: Will start in 9 seconds
In my case, I took the new files to OCR, saved them as PDFs, and removed the files after processing. But still, launchd started and stopped every 10 seconds. But why? The answer is quite easy: the Finder placed an invisible .DS_Store in that folder. My AppleScript did not remove it, but launchd was aware of that "new" file, and restarted endlessly. Fix: remove the .DS_Store as last action of your AppleScript:
set DeleteMe to alias "hd:any:path:to:a:folder:.DS_Store"
set rmMe to POSIX path of DeleteMe
try
    do shell script "rm " & quoted form of (rmMe)
end try
With this fix, launchd will stop restarting. There might be other ways to get rid off these .DS_Store's, but this was the easiest fix for me.
  Post a comment  •  Comments (13)  
  • Currently 1.89 / 5
  You rated: 1 / 5 (9 votes cast)
 
[21,198 views] Email Article To a Friend View Printable Version
Ease Mac OS / Windows Boot Camp switching System
I use a 2.33Ghz MacBook Pro as the main workhorse for my production business, and I have Windows XP SP2 installed via Boot Camp to run some Windows-only software that I need to run natively (ie not in Fusion or Parallels). However, I soon tired of switching the boot disk from 10.5.2 to XP and back. So I came up with this little timesaver by putting shortcuts to the System Preferences Startup Disk panel (in OS X) and the Boot Camp Control Panel (in Windows XP) on their respective desktops and dock. It saves me a couple of steps and makes the rebooting process acceptable.

In Mac OS 10.5.2, navigate to /System/Library/PreferencePanes, and find StartupDisc.prefPane. Create an alias of the StartupDisc.prefPane, and drag the alias to the Desktop or the Dock. I changed the icon to a Windows icon, and the text to Shortcut to Win XP.

While in Windows XP, open the Control Panel, then right-click on the on the Boot Camp Control Panel item. Select Send to Desktop from the pop-up menu to create a shortcut on the Windows Desktop, and rename as desired.

[robg adds: You can, of course, use the Option key during boot to select the startup disk. This method, however, might be easier for novices to use, or helpful if you want to restart the machine and walk away during the boot process.]
  Post a comment  •  Comments (12)  
  • Currently 2.36 / 5
  You rated: 1 / 5 (11 votes cast)
 
[121,445 views] Email Article To a Friend View Printable Version
Enable Help Viewer's debug mode System
While trying to debug a problem with Help Viewer (it's hanging with the spinning gear icon whenever I use the search field), I stumbled across this page, which includes a ton of information on debugging Help Viewer. Buried in the details is this tidbit on enabling Help Viewer's debug mode. Quit Help Viewer, then open Terminal and type:
defaults write com.apple.helpviewer HelpViewerDebugging -bool YES
Now when you launch Help Viewer, it will write a ton of output that you can view with Console (in /Applications » Utilities). With any luck, the information you see there may help you sort out the problem (either directly, or by running more accurate web searches). When you're done, turn off the debugging tool, unless you want your console logs filled with output. To disable logging, quit Help Viewer, then repeat the above command but change YES to NO.

Unfortunately, in my case, it didn't point me to a solution to the problem, though I now know it has something to do with an assertion failure in NSSearchFieldCell and an "invalid parameter not satisfying: aString != nil." Back to the troubleshooting...
  Post a comment  •  Comments (0)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[7,914 views] Email Article To a Friend View Printable Version
An easy way to run multiple instances of any program System
I've seen a few tips on different sites explaining how to run two copies of certain applications. Most of these involve creating a second copy of the Application bundle, which can be impractical if it contains too many resources, and is a hassle in any case.

Here's an easier way that I don't think anyone has posted here: Just run the application that you'd like to launch a second time from Terminal, using the open command with the --new (-n) flag. This will force an additional instance to be opened regardless of how many are already running. For example, if I wanted to run another copy of Mail, I'd do it this way:
  open -n /Applications/Mail.app
Remember that you can drag an icon to the Terminal window and it will insert its path, making this even simpler!

[robg adds: We've run a couple of hints on running multiple copies of the same application. This one used an AppleScript for Remote Desktop Connection 2.0, but could be extended for other applications. This much older hint used a Terminal command to find the actual application executable. Note that running multiple copies of one app as the same user may not work perfectly, especially if the app requires exclusive access to a file, or if you change preferences while two copies are running.]
  Post a comment  •  Comments (7)  
  • Currently 3.86 / 5
  You rated: 5 / 5 (14 votes cast)
 
[59,048 views] Email Article To a Friend View Printable Version