Hello - Let me preface my question with the fact that I am a newbie to AppleScript (but not to programming). I have searched the archives, but cannot seem to find an answer to this -
I have a Powerbook and a Novatel Wireless modem from Sprint PCS that I use to connect to the Internet when I am away from hotspots (802.11 networks).
I am trying to write a script to detect when the card has been inserted into the PC Card slot and perform the following actions:
Change the location (from “Automatic” to a new location I created called “Mobile”)
Emulate clicking the modem icon and selecting connect.
The goal is to insert the card and automate the steps for connecting.
Can this be done :?:
Thanks in advance for reading my post and any help you can offer,
This can only be done indirectly, that is, you cannot have the script just automatically run when you insert the card - to do that the Finder would have to offer ‘hooks’ that let you attach scripts to events such as a disk insertions, etc. (kind of like folder actions).
The only way you can do this is to have a background script running, checking periodically for the PC Card’s existence. When it detects the card it fires off and does what you want. However, this approach requires that the script be always running and present in your dock.
Additionally, just to compound matters further, the only way (AFAIK) to change the location is via GUI scripting , which means that you insert the card and then your machine appears to go crazy for a while, launching apps, clicking buttons, selecting menus, etc., etc. - not something that people normally expect to happen.
As much as it isn’t what you wanted, a standalone app that you run when you want to switch configs would be a better solution IMHO. At least you initiate the action.
Camelot - Thank you very much for the reply. You’ve given me a lot to think about. I had come to the painful realization about needing a continuously running script, but did not consider the GUI scripting side.
I did find that when the card is inserted a file named /dev/tty.pccard_serial is created. My initial thought was to search for the existence of that file and then execute the remaining actions. But I want to avoid any GUI script actions.