I'm trying to automate CCleaner, so far I can start the application and click the button that starts the cleanup job, however I'm relying on a delay
to determine when I should move onto the next portion of the script.
tell application "/Applications/CCleaner.app" to activate
tell application "System Events"
tell application process "CCleaner"
click button "Run Cleaner" of window 1
delay 10
end tell
end tell
I don't particularly like this approach and would prefer to detect when CCleaner is finished running (it may be much sooner or later than the 10 second delay).
While CCleaner is inactive, the button text is "Run Cleaner"; when CCleaner is active, the button text is "Cancel". Can someone advise how I check the text on the button? If I know how to do that I can do something like this:
tell application "/Applications/CCleaner.app" to activate
tell application "System Events"
tell application process "CCleaner"
click button "Run Cleaner" of window 1
delay 10
end tell
end tell
repeat
# ?
# ? if button text is "Run Cleaner" then exit repeat
# ?
delay 1
end repeat
# do more stuff
Best Answer
You can check every button of the window and wait until one is titled like you want :