Okay so I’m referencing this topic, http://bbs.applescript.net/viewtopic.php?id=22124 and I have a similar use for this, but while taking StefanK’s code for Disk Warrior and trying to apply it to my needs, I’m running into some issues.
I’m using FinderCleaner to clean mac files off my psp and when my psp is connected and I run FinderCleaner, it by default selects my psp so all i need it to do is click “Choose” on the “Choose a Folder” window. Then it needs to authenticate. Then select the button “Eject” when it’s done. Also, on the window with “Quit” and “Eject” it has no name for the window so I don’t know how to focus on it.
launch application "FinderCleaner"
tell application "FinderCleaner"
repeat until (exists window "Choose a Folder")
delay 0.5
end repeat
tell window "Choose a Folder" of process "FinderCleaner"
click button "Choose" of group 2
end tell
end tell
authenticate_changes()
to authenticate_changes()
tell application "System Events"
repeat until (exists window "Authenticate" of process ,"SecurityAgent")
delay 0.5
end repeat
tell window "Authenticate" of process "SecurityAgent"
tell group 1
set value of text field 2 to "mypasswordhere"
end tell
click button "OK" of group 2
end tell
end tell
end authenticate_changes
I have a problem when it gets to (tell window “Choose a Folder” of process “FinderCleaner”) it highlights the first quote on FinderCleaner saying (Expected end of line but found ".) I really don’t know what to do since I’m a newb at scripting and I’m learning the way everyone does, by taking someones example script and tweaking it. Help!
Hey Budgie, Thanks! Heh, I was actually able to compile the script and at least save it now. Sadly, I was only met with more issues…
For starters, when I open FinderCleaner from the Dock, it loads up the “Choose A Folder” window, but when the script opens FinderCleaner, it never actually loads. I have to then click it in the dock to get it rolling. Even when FinderCleaner is sitting at the “Choose A Folder” window and the script is running, it can’t actually find the window and just times out. Once again, the chunk for selecting “Choose” doesn’t work either because it can’t find the window.
Then when I isolate the authenticating section of the script and have FinderCleaner at the Authenticate window and run the script, it doesn’t do anything again. Just more timing out. So basically, as far as I can tell, nothing in the script is “working” even though it all passes the compiling. >.<
FinderCleaner isn’t a real application. It’s just an AppleScript applet with all disadvantages to script it.
For example in “System Events” there’s no process “FinderCleaner” but only a process “droplet”.
I tried a bit but all attemptions failed.
Maybe it’s easier to reinvent the wheel and write yourself a script with those or similar functions
Well thanks for trying StefanK. I just got a book from the libarary, Applescript: The Missing Manual, and I was gonna sit here and tinker with FinderCleaner until it worked so you just saved me a lot of time. I guess I’ll just have to make my own once I read the book.
Ok, well I got my Applescripting book which shed some light on the subject for me and I’m now able to script the input of the Administrator password with the following code, but I still can’t figure out how to delay it until i’m ready for it to run.
It would be ok if I could run the script below first, and then start up FinderCleaner and select the drive to eject manually and then when the Authentication window showed up, the script below would kick in.
activate application "SecurityAgent"
tell application "System Events"
tell window "Authenticate" of process "SecurityAgent"
tell group 1
set value of text field 2 to "myfakepassword"
end tell
delay .5
click the button "OK" of group 2
end tell
end tell
If i can figure out, or someone can help, how to delay this portion of script until the Authentication window shows up, you could apply this script to any situation that requires an Administrator password, assuming you know it’s coming ahead of time. You then would just need to alter the parameters of the repeat until. I just don’t know what to specify for the repeat until is all.