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


Click here to return to the 'Reverse Screen Sharing Grabber' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Reverse Screen Sharing Grabber
Authored by: aechadwick on Dec 03, '10 02:36:04PM
I'm the submitter. I spent more time with this the next day, and got it down a little simpler.

on Dr Cube, this Applescript:

if application "Screen Sharing" is running then
	
	do shell script "ps ax | grep " & (quoted form of "Screen Sharing") & " | grep -v grep | awk '{print $1}' | xargs kill -9"
	
else
	tell application "Screen Sharing" to open location "vnc://username:password@W89100AK7AP.local"
end if

saved as "ScreenSharingSwitch.app"

when triggered, this scans processes—if Screen Sharing is already running, it terminate the process; if Screen Sharing is not running, it grabs W89100AK7AP's screen. Thus, one call to start, or one call to stop.
on my W89100AK7AP, this Applescript:

do shell script "ssh Dr-Cube.local \"open /Library/Scripts/ScreenSharingSwitch.app\""

saved as "ScreenSharingSender.app"

this sends the call to Dr Cube to run the above script, superseding the previous .command-and-do-shell version.

*previous instructions already established the secure ssh key.

[ Reply to This | # ]
Reverse Screen Sharing Grabber
Authored by: aechadwick on Dec 04, '10 08:03:47AM
Asmus Vierck introduced the idea of using Keychain, an excellent point!

I made a new Keychain Item on Dr Cube named "ScreenSharingGrabber" (don't be mean, I just like to keep things simple)

then on Dr Cube, here is the most up-to-date version of the Applescript (v.3 at this point!)

tell application "Keychain Scripting"
	tell keychain 1
		unlock
		set theKey to first key whose name is "ScreenSharingGrabber"
		set theUsername to (account of theKey) as string
		set thePassword to (password of theKey) as string
	end tell
end tell

if application "Screen Sharing" is running then
	
	do shell script "ps ax | grep " & (quoted form of "Screen Sharing") & " | grep -v grep | awk '{print $1}' | xargs kill -9"
	
else
	tell application "Screen Sharing" to open location "vnc://" & theUsername & ":" & thePassword & "@W89100AK7AP.local"
end if
saved as "ScreenSharingSwitch.app"

I have been trying to keep this to free & built-in components. (I actually tried Remote Desktop via one of the work machines, but I could not automate "fullscreen," it always appeared as a window—the window had a "make fullscreen" button, but I could not find a term in Remote Desktop's AppleScript dictionary.)

My other goal is one-click operation—that's why the use of ApplecScript to make all the system calls. If operation isn't instant and foolproof, the effect is lost—and then I'm surrounded by people staring over my shoulder—only now they're slightly frustrated, because I failed at being clever!

[ Reply to This | # ]