• 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: Can't get the change download folder in Safari script to work - ui scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get the change download folder in Safari script to work - ui scripting


  • Subject: Re: Can't get the change download folder in Safari script to work - ui scripting
  • From: KOENIG Yvan <email@hidden>
  • Date: Sun, 13 Mar 2011 18:33:03 +0100

Nigel posted a perfect answer but I wish to explain, the way I work when I must use GUI scripting.

The first thing to do is to grab the description of the items to trigger with a tool like Accessibility Inspector which is delivered with the operating system.
It's the only one which I use because UI browser is too expensive for someone which build scripts for free to help other users.

Here is how I got your script doing the trick.

property workInProgress : true

set_download_folder("~")

on set_download_folder(dlFolder)
activate application "Safari"
tell application "System Events" to tell application process "Safari"


click menu item 6 of menu 1 of menu bar item "Safari" of menu bar 1 (* Preferences… *)
tell tool bar 1 of window 1
if workInProgress then
name of every button
--> {"Général", "Aspect", "Signets", "Onglets", "RSS", "Rempl. auto.", "Sécurité", "Extensions", "Avancées"}
end if
set General_loc to name of first button
click button General_loc
end tell
if workInProgress then
tell group 1 of group 1 of window General_loc
class of UI elements
--> {static text, text field, checkbox, static text, pop up button, static text, static text, pop up button, static text, pop up button, pop up button, button, static text, static text, pop up button, button, static text, pop up button, pop up button, static text}
name of every pop up button
--> {"Les nouvelles fenêtres s’ouvrent avec :", "Navigateur web par défaut :", "Moteur de recherche par défaut :", "Enregistrer les fichiers téléchargés sur :", "Effacer la liste des téléchargements :", "Supprimer les éléments de l’historique :", "Les nouveaux onglets s’ouvrent avec :"}
end tell
end if
tell pop up button 4 of group 1 of group 1 of window General_loc
click
if workInProgress then
name of every menu item of menu 1
--> {"Documents", missing value, "Autre emplacement…"}
end if
click menu item 3 of menu 1 (* reveal the sheet allowing us to select the Download folder *)
end tell
if workInProgress then
--When it's a work in progress, I use this code which exit if the sheet doesn't appear


repeat 10 times
if exists sheet 1 of window General_loc then
set sheet_available to true
exit repeat
end if
delay 0.2
set sheet_available to false
end repeat


if not sheet_available then error number -128
else
repeat until exists sheet 1 of window General_loc
delay 0.1
end repeat
end if
if workInProgress then
tell sheet 1 of window General_loc
class of UI elements
--> {button, button, button, group, grow area}
name of every button
--> {"Sélectionner", "Nouveau dossier", "Annuler"}
end tell
end if
keystroke "g" using {shift down, command down}


repeat until exists sheet 1 of sheet 1 of window General_loc
delay 0.1
end repeat


tell sheet 1 of sheet 1 of window General_loc
if workInProgress then
class of UI elements
--> {static text, text field, button, button, static text, grow area}
name of every button
--> {"Aller", "Annuler"}
end if
set value of text field 1 to dlFolder
click button 1
end tell


click button 1 of sheet 1 of window General_loc
click button 1 of window General_loc


end tell
end set_download_folder

Yvan KOENIG (VALLAURIS, France) dimanche 13 mars 2011 18:32:39


 _______________________________________________
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: Can't get the change download folder in Safari script to work - ui scripting
      • From: Tommy Bollman <email@hidden>
References: 
 >Can't get the change download folder in Safari script to work - ui scripting (From: Tommy Bollman <email@hidden>)

  • Prev by Date: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Next by Date: Re: Converting UNIX TIME STAMP to Mac Os X Date
  • Previous by thread: Can't get the change download folder in Safari script to work - ui scripting
  • Next by thread: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Index(es):
    • Date
    • Thread