title: Applescript for detecting and automatically connect internet when USB modem plugged in
body: <p>I'm new here. And I need help on applescript.</p>
  
  <p>Currently i'm using USB Modem to connect to internet, it's an everyday routine so i can work. But i want to make it run automaticaly when i plugged the USB modem to my MBP, and run script to connect internet with using configuration that already set.</p>
  
  <p>Here is the script that i use to connect to Internet.</p>
  
  <pre><code>tell application "System Events"
  tell current location of network preferences
      set modem to service "Flexi EVDO"
      set isConnected to connected of current configuration of modem
      if isConnected then
          disconnect modem
      else
          connect modem
      end if
  end tell
  end tell
  </code></pre>
  
  <p>I ran this script using automator and save it as App.</p>
  
  <p>What i want to achieve is if i can run this script directly when i plugged my USB Modem.
  I'm stuck at detecting the modem script. I have no idea about this.</p>
  
  <p>Can anyone help me? Thanks in advance. Really appreciated every comments.
  Sorry for my bad english.</p>
  
  <p>Thanks! again. :)</p>