tags:

views:

201

answers:

1

Hello,

I would like to make an application that will run on my computer that will change the "Default Printer" in the "Printers & Fax" Preference Pane of "System Preferences" through AppleScript?

I want it to change the printer based on my wireless network that I am on. I will quit and start with every network change if I have to, but ideally, I would like it to do that automatically for me.

How might I go about doing this? If you need the IP address, network names, and or printer names, leave a comment and let me know. There are 3 printers I want it to switch between and 3 wireless networks I want it to switch between.

Thanks!

+1  A: 

Something like this will get you started to grab the current location. You'll need to trigger this when you change the location, and then once it grabs the location, you'll need an if else statement to walk through yoiur different printers. MacScripter is a great place for Applescript help; someone has proabably already done what you want to do: MacScripter. There are also ways to get network location in the shell, which would be faster that Applescript.

And there's MarcoPolo - Context-aware computing for Mac OS X, an app that will do what you want without writing an Applescript.

tell application "System Preferences"
   activate
end tell

tell application "System Events"
   tell application process "System Preferences"
       set frontmost to true
       click menu item "Network" of menu "View" of menu bar 1
--you may need a delay here, adjust to suit
delay 1
       set machineLocation to value of pop up button 1 of window "Network"
   end tell
end tell
tell application "System Preferences" to quit
songdogtech
Yes, I put a post on MacScripter, but the program didn't work, and when I replied no one answered, so I figured I would give this a try.Thanks!
Ben
I got something that I think will work... thanks everyone!
Ben