• 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
UI Scripting menu items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UI Scripting menu items


  • Subject: UI Scripting menu items
  • From: Ken Liu <email@hidden>
  • Date: Wed, 9 Apr 2003 23:22:50 -0400

Hi,

I'm fairly new to both AppleScript and UI scripting. Please be indulgent with me if this question has an obvious answer.

This is my script (it's supposed to get a list of the network locations defined on the system and allow the user to choose one -- not very useful yet but later on I was going to make it toggle between settings each time it's activated):

tell application "Finder"
activate
end tell

tell application "System Events"
set current_process to process 1 whose frontmost is true
tell process "Finder"
set frontmost to true
set location_list to the title of every menu item of menu "Location" of menu item "Location" of menu "Apple" of menu bar 1
set location to (choose from list location_list default items "Automatic" with prompt "Pick the location:") as string
tell menu bar 1 to click menu item location of menu "Location" of menu item "Location" of menu "Apple"
delay 1
end tell
set frontmost of current_process to true
end tell


I'm running into two problems

1. Sometimes the list of network locations is not properly populated. I have "Home" and "School" defined as locations, but sometimes only "Network Preferences..." shows up as a choice in the location_list. At other times, all the menu items do show up. I've put delay calls in all sorts of places and can't find a consistent pattern. How can I make it work consistently?

2. This is the bigger problem: even when the script seems to "work" it does not. The script terminates but I'm still in the Finder, rather than back in the current_process as I expect. And here's the thing that really baffles me, _until_ I click on the apple menu myself, the network location is not in fact switched! In other words, the script seems to "queue" up the clicking action and not execute it until I manually go and click on the apple menu itself, at which point it goes ahead and performs the UI action it's supposed to. This is best seen when I select the "Network Preferences..." option. The Finder just sits there and does nothing until I click on the apple menu, and the moment I do the Network Preference pane launches.

And if I switch to another application before I click on the apple menu, the script simply does not do anything.

I've changed the delay time with no improvement.

Any suggestions on how I can get this script to do its thing instead of just queuing up the "click"?

Thank you for your help

Ken
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: UI Scripting menu items
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: can't get it to work
  • Next by Date: Re: mac script size revisited
  • Previous by thread: [ANN] Matematica 2
  • Next by thread: Re: UI Scripting menu items
  • Index(es):
    • Date
    • Thread