Skip to content

Instantly share code, notes, and snippets.

@anamorph
Last active December 2, 2015 18:10
Show Gist options
  • Save anamorph/323b96c1595e5ecf6131 to your computer and use it in GitHub Desktop.
Save anamorph/323b96c1595e5ecf6131 to your computer and use it in GitHub Desktop.
applescript-mslync-update-location.scpt
(*
applescript-mslync-update-location
author: nicolas.david@anamor.ph
desc: the idea with this is to update your location in Microsoft Lync according to your network location.
update the following to adapt to your usage:
MYNIC to your network interface name
MYSSID to your wifi's ssid
MYIPRANGE to your wireless network ip range (referenced above via MYSSID)
Ex: 192.168
*)
set MYNIC to ""
set MYSSID to ""
set MYIPRANGE to ""
(*
Edit below at your own risk !
*)
if application "Microsoft Lync" is running then
set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
set MYIP to do shell script "ifconfig " & MYNIC & " | grep -v 'inet6' | grep 'inet' | awk '{print $2}'"
if SSID is MYSSID then
tell application "System Events"
tell process "Microsoft Lync"
if MYIP starts with MYIPRANGE then
set value of text field 1 of window "Microsoft Lync" to "VPN/Offsite"
else
set value of text field 1 of window "Microsoft Lync" to "ssid is: " & SSID & ". I'm in my home network."
end if
end tell
end tell
end if
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment