• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: scripting the Airport menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripting the Airport menu


  • Subject: Re: scripting the Airport menu
  • From: Bill Cheeseman <email@hidden>
  • Date: Mon, 19 Dec 2005 06:21:52 -0500
  • Thread-topic: scripting the Airport menu

on 2005-12-18 11:18 PM, doug rogers at email@hidden wrote:

> Is there any way to script selecting/clicking on items in the Airport
> Icon menu popup menu's in the Finder

Yes, using GUI Scripting. Here's a little script I use to turn off AirPort
Power. It will show you the technique. This requires Mac OS X 10.4, in which
the Menu Extras became much more accessible to GUI Scripting.

The hard part of scripting these "Menu Extras" is that most of them don't
have names, and using the index of the Menu Extra is flaky because it
depends on the current contents and orders of the Menu Extras menu bar,
which can change. The most stable technique I have found is to use negative
indexes counting from the right, as shown here. You have to set the index to
the value based on which Menu Extras you have turned on.

-- TURN OFF AIRPORT POWER
-- Set the airportIndex to suit your setup
-- (for best stability, count from the end)

property airportIndex : -5

activate application "SystemUIServer"
tell application "System Events"
    tell process "SystemUIServer"
        set airportItem to menu bar item airportIndex of menu bar 1
        click airportItem
        tell menu 1 of airportItem
            if title of menu item 1 does not start with "AirPort" then
                beep
                display dialog "This is not the AirPort menu extra." buttons
{"OK"} default button "OK"
                return
            end if
            if title of menu item 2 ends with "Off" then
                click menu item 2
            end if
        end tell
    end tell
end tell

Courtesy of PreFab UI Browser. <http://www.prefab.com/uibrowser/>

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >scripting the Airport menu (From: doug rogers <email@hidden>)

  • Prev by Date: scripting the Airport menu
  • Next by Date: Re: scripting the Airport menu
  • Previous by thread: scripting the Airport menu
  • Next by thread: Re: scripting the Airport menu
  • Index(es):
    • Date
    • Thread