So this is my first applescript, but I’ve used other programing languages before …
I have written a script to delete the default fonts from the current users library. It works but “UI elements” must be enabled in order to grab the username, so I added a shell script to enable UI, but I cannot seem to be able to make it work after enabling “UI elements”
Here is my code …
tell application "System Preferences"
activate
set current pane to pane "com.apple.preferences.users"
end tell
set user_name to ""
set pwd to "password"
tell application "System Events"
if UI elements enabled then
tell tab group 1 of window "Accounts" of process "System Preferences"
click radio button 1
delay 2
copy value of text field 2 to user_name
end tell
else
tell me to do shell script ¬
"touch /private/var/db/.AccessibilityAPIEnabled" password ¬
pwd with administrator privileges
-- here is where I want it to do what is after the "then" statement above before disabling "UI elements" again, but if I simply copy the text here it does not work
tell me to do shell script ¬
"rm /private/var/db/.AccessibilityAPIEnabled" password ¬
pwd with administrator privileges
end if
end tell
tell application "System Preferences" to quit
try
tell application "Font Reserve Client" to quit
end try
try
tell application "Finder"
activate
select folder "Fonts" of folder "Library" of folder user_name of folder "Users" of startup disk
set the selected_fonts to contents of selection
delete selected_fonts
tell folder "Library" of folder user_name of folder "Users" of startup disk to close
end tell
end try
Any info would be greatly appreciated