Jan 12, '11 07:30:00AM • Contributed by: withdave
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:
- Copy this script into a new AppleScript Editor document and save it as file format Application and with the 'Stay Open' checkbox checked. Name it something useful like 'Trigger Shared Screen Back To My Screen.'
- Insert a USB flash drive into your Mac and rename its volume to 'Trigger'; case doesn't matter. If it was already mounted make sure it will eject. It must be ejectable for this application to work.
- Start this application. It will eject the volume.
- Start your remote screen sharing session.
- Whenever you want to revert back to your screen without involving the remote computer, unplug the flash drive and plug it in again. Once you regain control of your screen the flash drive will automatically eject again to become ready for the next trigger.
- When you are done with all screen sharing Quit this application via one of the usual methods.
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.]
