10.6: Switch remote iChat shared screen back without disrupting the user

Jan 12, '11 07:30:00AM

Contributed by: withdave

Snow Leopard only hintGood 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:

Note: Any externally mounted device will do: external hard drive, memory card reader, camera, cell phone, etc. Be aware that if the device is chargable via the USB cable you could be reducing battery life if you plug it in and out an extreme number of times.

Tip: Use a USB extension cable to keep the flash drive within easy reach, or consider using a USB Mini Memory Card reader with a long cable for easy reach. I find it easier plugging memory cards in and out of a slot than plugging USB cables.

Another tip: After you click on the miniature window to go back to the remote screen, if you don't further move the mouse the remote user will see no disruption of their cursor location or current activity.

I also have a version which doesn't require Universal Access to be turned on, but the screen switch is done under iChat's nose so its miniature window still acts like you haven't switched back yet. (Everything still functions normally, you can click it to go back to the remote machine, it's just doesn't show the correct computer screen inside it until you 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


[crarko adds: I haven't tested this one. It also looks to me that Universal Access is enabled by default in Snow Leopard.]

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20110111033235997