Re: Can't get the change download folder in Safari script to work - ui scripting
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: Tommy Bollman <email@hidden>
- Date: Sun, 13 Mar 2011 19:25:32 +0100
Hello Nigel and Yvan and thanks.
I figured out (read me to ) that I could use defaults write. The only problem is that I can't
get Safari to update its internals without closing and reopening it. Then I have to take action
to have it open with the same tabs again, and the tabs can either be many, or to slow connections.
I will set up an apache proxy server, but haven't got around to that yet. So I guess I'll stick with Yvans solution -Thanks alot, I'll study it with accessibility inspector at hand.
Hopes everything is good with you, It is a lot of school work here, but i'll eventually catch up.
Tommy
The thing was is that I can't
Den 13. mars 2011 kl. 18.33 skrev KOENIG Yvan:
> 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
Best regards
Tommy Bollman
--------------------------------------------------------------------------------------------------
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review
and be implemented it wasn't worth doing.
_______________________________________________
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