How do I connect my Mac to Wi-Fi automatically?
Mac OS X should automatically join any known networks, as reported in the network applet.
After you select the Airport service in the list of the network connection, you can click on the Advanced button, which will show a dialog that allows you to select your preferred networks, and to sort them.

  



The Mac will not automatically connect if it doesn't find any of the preferred networks, or if the preferred network requires a "password" that is unknown to the Mac.