-1

What is the AppleScript to identify the current status of MacBook Pro's network connection (Yosemite 10.10.3)

  1. Connected via Iphone USB on/off (Hotspotting to Iphone)
  2. Connected via WIFI ON on/off
  3. Connected via Ethernet on/off
  4. No Connection

I want to add this condition check into my Automator Workflow, so workflows run similar to many of the IOS Apps that have the setting "do not send files / do not download unless connected to WIFI"

  • Hi, is there anything you have tried so far ? Which one of the connections would you allow and which one would you block – Ruskes May 5 '15 at 23:46
  • Sorry Buscar, I have no idea why you think your comment is relevant/helpful. What does it matter which ones I use (aka allow/block?) As some point most individuals would use all 4 connection options. These 4 are standard. – sea May 6 '15 at 3:31
  • Just wondering is it a automatic process or do you have to choose. And it does matter, since the script would be different pending the activity. And still wondering if you have tried to do anything your self so far, so we can avoid those roads. – Ruskes May 6 '15 at 3:43
  • Using Terminal, list of connection ports is possible 'networksetup -listallhardwareports'. Automator can run a shell script. Prefer to conditional check the service via AppleScript. As not sure the iphone USB connection comes up as hardware port. – sea May 6 '15 at 3:59
1

If you have Network menu bar item/icon in top right menu bar. You can do:

tell application "System Events" to tell process "SystemUIServer"
    value of attribute "AXDescription" of menu bar items of menu bar 1
end tell

To get connection status. For example:

{"Wi-Fi, four of four bars, with WiFiNetworkName.", "Battery: Charged ", "Clock"}

Then you can parse the string/list to check if a certain word is present.

  • Nice. Current WIFI menu bar icon (?think your calling network menu bar item) shows only WIFI connection information. Icon of WIFI. Network Preferences in System Preferences has the full list of network connections (ie iphone USB (hotspotting using iphone)). Here, click cog, shows me these items are "services", so we must be able to direct query these ebjects. yes? – sea May 6 '15 at 3:31
  • Found an App that uses network connections as conditional checking, as part of the App's features and then enables user to build out a profile. (controlplaneapp.com/feature-list). – sea May 6 '15 at 3:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .