简体   繁体   中英

Screen Sharing with Applescript and Automator

Desired Results: 1. Open Screen Sharing.app 2. Input desired IP address and connect (changes depending on environment) 3. Auto Mute Microphone 4. Wait for session to connect 5. Auto switch to Observe Mode 6. Session is complete and Screen Sharing.app is closed 7. Auto UnMute Microphone

What's been done and needs: 1. I have successfully done steps 1, 2, 3, 6, and 7. 2. I am stuck trying to find a way to trigger the Observe Mode without using a timer. If the desired connection isn't complete within the designated time or the window is not selected, it will not work and an error will occur. 3. I am using a combination of Automator and Applescript. Most of the items are setup by Applescript.

My question: How can I tell Automator or Applescript to wait for Screen Sharing to finish connecting before proceeding with the remaining tasks?

Except GetUrl instruction, screen sharing app is not scriptable, then you cannot ask it if the vnc connection is on or not. Screen sharing app has an internal timeout which triggers an error window ("can't open...") after sometime.

So you can't know when the screen sharing will have open the windows or just the error dialog. The work around I used is to check, before opening vnc url, that your IP address answers to ping requests. But you may have some servers which don't answer !

The second part is easier because the switch to observe mode can be done via keystroke (screen sharing menu) with script bellow :

tell application "Screen Sharing" to activate
tell application "System Events"
tell process "Screen Sharing"
    keystroke "x" using {option down, command down}
end tell
end tell

Of course, this is only valid once screen sharing has open the vnc window. And you must allow, in system preferences, the GUI scripting via your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM