• 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: GUI script a popup button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI script a popup button


  • Subject: Re: GUI script a popup button
  • From: Christopher Stone <email@hidden>
  • Date: Thu, 11 Aug 2016 20:33:29 -0500

On Aug 11, 2016, at 12:47, Mitchell L Model <email@hidden> wrote:
I have something that used to work but no longer does (possibly because I upgraded from 10.8 to 10.11 and behavior is a little different). I often want use AppleScript GUI scripting to click a certain item in a popup menu.


Hey Mitchell,

What pop-up menu in what app?

When GUI-Scripting this is always relevant.

An example is that I haven't found anyway to directly script setting the "Open with" of a file.

-------------------------------------------------------------------------------------------
#  Directly set Open-With for a given file.
-------------------------------------------------------------------------------------------

tell application "Finder" to set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
set theItem to item 1 of finderSelectionList

set theApp to alias ((path to startup disk as text) & "Applications:App-Store-Applications:Archive_Tools:The Archive Browser.app:")

tell application "System Events" to set default application of theItem to theApp

-------------------------------------------------------------------------------------------
# Manipulate the Open-With menu in the Finder with GUI-Scripting.
-------------------------------------------------------------------------------------------

tell application "System Events"
   tell application process "Finder"
      tell menu 1 of menu bar item "File" of menu bar 1
         click

         

         tell menu item "Open With"
            click
            delay 0.1 -- Adjust delay as necessary to allow the “Open With” menu to populate.

            

            tell menu 1
               select (first menu item whose name starts with "The Archive Browser")
            end tell

            

         end tell
      end tell
   end tell
end tell

-------------------------------------------------------------------------------------------

I've used select above, so the user can choose to “Open With” or “Always Open With”.

I'm not going to bother to script the Get-Info window – the same techniques will work.

It is also possible to set the default “Open With” app for whole classes of files.

A place to start:

http://stackoverflow.com/questions/9172226/how-to-set-default-application-for-specific-file-types-in-mac-os-x

It seems to me that Shane cracked that problem with ASObjC a while back, although I can't find it in my archives.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: GUI script a popup button
      • From: Mitchell L Model <email@hidden>
    • Re: GUI script a popup button
      • From: Jim Underwood <email@hidden>
References: 
 >GUI script a popup button (From: Mitchell L Model <email@hidden>)

  • Prev by Date: Re: Return of the bug: "tell me to activate"
  • Next by Date: Set List View Attributes of a Finder Window Using System Events
  • Previous by thread: GUI script a popup button
  • Next by thread: Re: GUI script a popup button
  • Index(es):
    • Date
    • Thread