Section 9.1. Internet Connect


9.1. Internet Connect

If you connect to the Internet using a dial-up modem or an AirPort wireless card, Internet Connect is your best friend. Located in your Applications folder, Internet Connect lets you connect and disconnect to the Internet at will. And if you're having connection problems, Internet Connect can help by showing you how strong your wireless signal is.

Even better, Internet Connect is 100% scriptable. If you want to automate your connecting, the Internet Connect/AppleScript combo makes it a cinch.

9.1.1. Dialing Up to the Internet

Dial-up connections, while only a fraction the speed of DSL or cable, have a number of unique advantages. For one thing, dial-up is much cheaperabout 20% the cost of a high-speed connection, in many areas. For another, dial-up connections are available everywherea major advantage if you happen to live in Guam. Plus, you can access a dial-up connection even when traveling, as long as there's a phone jack where you're going.

The best part about a dial-up connection, however, is that you can create an AppleScript to automatically connect you to the Internet, wherever and whenever you want. Here's how:

If you connect to the Internet using a high-speed connection, turn off your connection before trying this dial-up script.

set thePhoneNumber to the text returned of (display dialog ¬         "Please enter the phone number to connect to:" default answer "") set theUsername to the text returned of (display dialog ¬         "Please enter your username:" default answer "") set thePassword to the text returned of (display dialog ¬         "Please enter your password:" default answer "") tell application "Internet Connect"     --This is the part that actually connects:     connect to telephone number thePhoneNumber as user theUsername ¬         with password thePassword end tell

Using a series of three dialog boxes (Figure 9-1), that script is all you need to dial up to the Internet.

If you regularly connect to the same phone number, you might as well preprogram your connection information into Internet Connect Internal Modem. On the other hand, if you just want to test out a new dial-up phone number once, the previous script is a quick, painless way to go about it.

9.1.2. Finding AirPort Signal Strength

Surfing the Internet wirelessly is great, but it's got some annoying requirements. First, you need a wireless card to insert into your Mac. Next, you need a wireless base stationa small device that broadcasts your Internet connection throughout your house or apartment. Finally, you have to be within range of the base stationusually a few hundred feetto pick up the wireless signal on your Mac.

The trouble is, if you have a laptop, the signal strength changes as you move around. Taking the computer from your kitchen to your basement, for example, could make the signal twice as weak. Of course, the weaker your signal is, the slower you'll be able to connect to the Internet, so you should find the part of your house that has the best signal.

Like so many other tasks, AppleScript makes this quite easy. Simply run the following script, and you'll get a dialog box whenever your signal is exceptionally strongor exceptionally weakas you walk around your house:

--Part 1: tell application "Internet Connect"     set strongestSignalSoFar to the signal level of AirPort configuration 1     set weakestSignalSoFar to the signal level of AirPort configuration 1 end tell --Part 2: repeat     delay 3     --Part 3:     tell application "Internet Connect"         set currentSignal to the signal level of AirPort configuration 1     end tell     --Part 4:     if currentSignal > strongestSignalSoFar then

Figure 9-1. Top: Type the phone number that your ISP (Internet Service Provider) gave you to connect to the Internet. (Unfortunately, if you use AOL, this won't work.)Middle: Type your Internet account's user name; capitalization matters. Bottom: Type your password (capitalization still matters). Make sure no one's looking over your shoulder, though, because AppleScript shows your password in plain text.


        display dialog "You're getting the strongest signal so far: " ¬             & currentSignal & "%"         set strongestSignalSoFar to currentSignal     --Part 5:     else if currentSignal < weakestSignalSoFar then         display dialog "You're getting the weakest signal so far: " & currentSignal & "%"         set weakestSignalSoFar to currentSignal     end if end repeat

Here's how the script works:

  • Part 1 gets the current strength of your AirPort connection, on a scale from 0 (no signal at all) to 100 (standing right next to your base station). The script then places the signal strength in both the strongestSignalSoFar and weakestSignalSoFar variables. Later in the script, you'll refer back to these variables to check if your signal is at its highest or lowest level yet.

When scripting Internet Connect, you have to refer to AirPort configuration 1 rather than just the AirPort configuration (which would make more sense). That's because, in theory, you could have more than one AirPort card connected to your Mac, and Internet Connect needs to know which one you're referring to.

  • Part 2 starts a repeat loop, pausing for 3 seconds each time before it proceeds. Since you don't include a specific number right after the repeat statement, your script will repeat its signal-checking code until you either click Cancel in a dialog box or click Stop in Script Editor.

  • Part 3 gets AirPort's signal strength at the moment and puts it into the currentStrength variable.

  • Part 4 compares the current signal to your previously strongest signal. If the current signal is stronger, you see a dialog box telling you that you're getting exceptionally good reception (the script then updates the strongestSignalSoFar variable to reflect your new, stronger signal).

  • Part 5 on the other hand, shows you a different dialog box (Figure 9-2), if your signal is the weakest it's been so far. That's a sure sign that you should avoid using your wireless connection in that part of your house.

Figure 9-2. If your signal strength drops below 50 percent, your connection could slow down noticeably. Therefore, try to find a part of your house that has a strong signal and is convenient to work in.


Run the script, and then start walking around your house. As you go from room to room, you'll notice your signal strength fluctuate. Once you find a room with a strong signal (ideally 60% or higher), you can sit down and surf the Web, confident that you're not losing speed to poor reception.

Don't forget to walk outside with your laptop, too. You might get a strong signal on your front porch, for example, which would let you browse outside in your rocking chair on a nice summer day.



AppleScript. The Missing Manual
AppleScript: The Missing Manual
ISBN: 0596008503
EAN: 2147483647
Year: 2003
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net