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. 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:
It seems to me that Shane cracked that problem with ASObjC a while back, although I can't find it in my archives.
|