Greentings
I’m a new applescript user. I’m trying to make a script that change my network opitions in System Preferences (because I have two types of connections).
Well, at least I got open system preferences and choose the network (at least)
But when I try to change the popup menu from “Network Status” (default opition) to Internal Modem for example it doesnt work. I tryed to use set, click, popup button… notting works.
How then I change a opition from a popup menu using applescript. It possible? There are another way to make it?
above allthank you
mafrota
Hi, mafrota!
When you look at the Network Preference Pane, do you see the popup menu above the “Network Status” popup menu? It probably says “Automatic”
If you click on this, you will get a menu with (probably, if you haven’t done anything to this menu) “Automatic, a separator, New Location…, Edit Locations…” Select “New Location…”, give it a name, like “Enet”, select the “Show:” popup menu, select “Ethernet” and put in your ethernet settings.
Do this again for your modem settings, Select “New Location…”, give it a name like “Modem”, go to the “Show:” popup and put in your settings for modem.
Once you have this set up, you can use the “Locations” menu item in the Apple menu. To automate this, first go to the “Universal Access” control panel and be sure that “Enable access for assistive devices” has a check next to it. It’s down at the bottom of the preference pane. Then run this script to select Ethernet:
application "Finder" to activate
tell application "System Events"
tell process "Finder"
click menu item "Enet" of menu "Location" of menu item "Location" of menu "Apple" of menu bar item "Apple" of menu bar 1 --this is one line starting with "click"
end tell
end tell
Change “Enet” to “Modem” and save script as (so you have two scripts) to switch to the modem.
As a problem for the student, check out the Standard Additions command “choose from list” for how to select from a list.
Hi Dennis,
Thank you.
But my main question still. Is it possible to change a popup menu using an applescript?
Because I wanna choose automatically a modem script and to do that I must change a popu menu option. Are there another way to change automatically a modem script?
I must be automatically because the user will do that is a very very newbie.
I already check the Standard Additions command “choose from list”, and tryed to use it. But noting happens.
You have to set your locations, then you can use a script to change between locations. In my example, I had only two locations, but you can have as many locations as you please (I guess the limiting factor would be hard disk space ). You can set up as many different modem settings as you want. Just give each a name. Then you set up a list in AppleScript and use the “choose from list” command to select which modem location you want. Here’s an example:
property networkList : {"ModemSettings1", "ModemSettings2", "EthernetSettings1", "EthernetSettings2", "SomeMoreModemSettings", "YetAnotherModemSetting"} --one line starting with "property"
set settingSelected to choose from list networkList with prompt "Choose the Network Setting" without multiple selections allowed
tell application "Finder" to activate
tell application "System Events"
tell process "Finder"
click menu item settingSelected of menu "Location" of menu item "Location" of menu "Apple" of menu bar item "Apple" of menu bar 1 --this is one line starting with "click"
end tell
end tell
As for selecting a popup menu, perhaps this forum topic may be of assistance, though I like my way, because I like the Location menu for changing network settings, it was designed for that.