Good news for folks who remote control screens over the internet with iChat. Now you can use the plugging in of a USB flash drive, or any other mountable device, to automatically signal your Mac to switch from the remote computer screen back to yours. You no longer have to rudely interrupt the user at the other end by moving their cursor out from under them. And you don't have to communicate with them in advance to warn them about it. They remain blissfully unaware of your leaving and returning.
Only tested on Snow Leopard (10.6.6.).
Note: This hint requires Universal Access to be enabled. To make sure it is go to System Preferences » Universal Access and check 'Enable access for assistive devices.' I believe it is checked by default in 10.6.x.
Here's what to do:
-- Trigger A Shared Screen To Background - AppleScript
-- Only tested on Snow Leopard (10.6.6.) Coded January 10, 2011
property volumeName : "Trigger"
property IdleWaitSeconds : 5 -- recheck mounted volumes this often
on run
-- All work is done in the idle handler
end run
property idleRecurse : false
on idle
if idleRecurse then return IdleWaitSeconds
try
set idelRecurse to true
-- Note: Can't use Finder because if user has preferences set to not show
-- mounted volumes on the desktop they won't be in its items.
set allDisks to do shell script "ls /Volumes"
set allDisks to every paragraph of allDisks
log allDisks
if allDisks contains volumeName then
-- re-eject the trigger volume
set ejectResult to do shell script "diskutil unmount " & quoted form of ("/Volumes/" & volumeName)
if application "iChat" is running then -- New in Leopard
tell application "iChat"
if exists active av chat then
-- There is a video chat or screen sharing. Screen sharing shows
-- up as an audio chat.
set isScreenSharing to (count of video chats) is 0
if isScreenSharing then
tell application "System Events"
tell process "iChat"
repeat with aWindow in windows
set wTitle to title of aWindow as string
if wTitle is "My Computer" then
click button 2 of aWindow
end if
end repeat
end tell
end tell
end if
end if
end tell
end if
end if
on error errorMsg number errNumber
log "Idle error: " & errorMsg & ": " & errNumber
end try
set idelRecurse to false
end idle
Mac OS X Hints
http://hints.macworld.com/article.php?story=20110111033235997