Hi,
I absolutely loved CCleaner for Windows and since I switched to Mac, I love the Mac version! However, the Windows version has this cool "close program after cleaning" feature and the Mac version hasn't...yet? I really hope to see this come to CCleaner for Mac one day.
In the mean time, I made an app with applescript that starts the CCleaner app and automatically runs the cleaning process. After that, I still have to quit CCleaner manually. It would be awesome to have the "close program after cleaning" feature.
Like that, I will even be able to make an app (with automator and applescript combined) which:
1)...quits all running apps
2)...starts CCleaner
3)...runs the cleaning process automatically (written in applescript to click on the "Clean" button)
4)...quits CCleaner (set in the options of CCleaner once the option is there)
5)...shuts down my Mac or puts it to sleep
Now, that would be very convenient and handy: automatically clean my Mac and shut it down with one click on my app-icon!
So, hope to see the "close program after cleaning" soon...
But anyway: thanks for making this piece of software. It's really convenient to have all the cleaning facilities (histories, caches, downloads, other apps, trash, ............) in one place!
Cheers!
Joe D. (architect)
Quit CCleaner for Mac automatically after running?
Started by
joedarch
, May 24 2012 06:52 AM
7 replies to this topic
#1 OFFLINE
Posted 24 May 2012 - 06:52 AM
#2 OFFLINE
Posted 30 May 2012 - 04:53 AM
I forgot something: ...So, for now, I just run my applescript to automatically startup Ccleaner and (automatically) do the clean process and then, I run another script to quit all apps and shutdown the mac. I've setup both applescript apps with their own icon and placed them on my dock. So, with two clicks on my dock I clean and shut down my Mac.
#3 OFFLINE
Posted 30 May 2012 - 11:37 AM
the developer read all threads and suggestions are often added to ccleaner, as you've a proof of concept already, I see a good chance of this being considered. would you mind pasting your AScript into a code box in a reply to this thread.
ADVICE FOR USING CCleaner'S REGISTRY INTEGRITY SECTION
DON'T JUST CLEAN EVERYTHING THAT'S CHECKED OFF.
Do your Registry Cleaning in small bits (at the very least Check-mark by Check-mark)
ALWAYS BACKUP THE ENTRY, YOU NEVER KNOW WHAT YOU'LL BREAK IF YOU DON'T.
CCLEANER, RECUVA, DEFRAGGLER AND SPECCY DOCUMENTATION CAN BE FOUND AT www.piriform.com/docs
Link to Winapp2.ini explanation
DON'T JUST CLEAN EVERYTHING THAT'S CHECKED OFF.
Do your Registry Cleaning in small bits (at the very least Check-mark by Check-mark)
ALWAYS BACKUP THE ENTRY, YOU NEVER KNOW WHAT YOU'LL BREAK IF YOU DON'T.
CCLEANER, RECUVA, DEFRAGGLER AND SPECCY DOCUMENTATION CAN BE FOUND AT www.piriform.com/docs
Link to Winapp2.ini explanation
#4 OFFLINE
Posted 31 May 2012 - 01:36 AM
Thanks for the reply - I figured this feature will/might be there one day as it's there in the Windows version and it's not a Windows specific feature. Of course, I can post my AScripts - I should have done that in the first place! I'm at work now and don't have them with me, I'll post them tonight or tomorrow.
In the meantime, I'm still searching for scripts or other ways to shut CCleaner down automatically after having done its job.
I tried to implement an "idle" handler in a script (meaning: it checks the idle state of the system for x seconds, after which it shuts down CCleaner), but that doesn't work as this handler doesn't seem to detect that CCleaner is still cleaning. So it shuts down while still cleaning. So now I'm looking for some other way to detect whether CCleaner is still busy cleaning or analyzing. That's the rather hard part: I have to find some proof of CCleaner having done. It's not about the "process CCleaner" running, it's all about its busy/active state: as long as it's doing a task (cleaning/analyzing), it should not quit yet.
Maybe there's some sort of file (maybe a log or something?) that CCleaner alters or produces after having done its cleaning job? Does anyone know about that? Or something else like that? This can be checked by the script with "IF...THEN" so, that would be a way to quit CCleaner only when it's done with its task...
Anyway, I'll post what I've got so far tonight or tomorrow!
Cheers,
Joe D.
In the meantime, I'm still searching for scripts or other ways to shut CCleaner down automatically after having done its job.
I tried to implement an "idle" handler in a script (meaning: it checks the idle state of the system for x seconds, after which it shuts down CCleaner), but that doesn't work as this handler doesn't seem to detect that CCleaner is still cleaning. So it shuts down while still cleaning. So now I'm looking for some other way to detect whether CCleaner is still busy cleaning or analyzing. That's the rather hard part: I have to find some proof of CCleaner having done. It's not about the "process CCleaner" running, it's all about its busy/active state: as long as it's doing a task (cleaning/analyzing), it should not quit yet.
Maybe there's some sort of file (maybe a log or something?) that CCleaner alters or produces after having done its cleaning job? Does anyone know about that? Or something else like that? This can be checked by the script with "IF...THEN" so, that would be a way to quit CCleaner only when it's done with its task...
Anyway, I'll post what I've got so far tonight or tomorrow!
Cheers,
Joe D.
#5 OFFLINE
Posted 31 May 2012 - 12:41 PM
Ok, I'm here...
Here's the first script to startup CCleaner and run the cleaning process:
tell application "CCleaner"
activate
tell application "System Events"
click button "Run Cleaner" of window "Ccleaner" of process "CCleaner"
end tell
end tell
And here is the other script, to shut down all apps and shutdown the Mac:
tell application "System Events" to set the visible of every process to true
set white_list to {"Finder"}
try
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
set this_process to item i of the process_list
if this_process is not in white_list then
tell application this_process
quit
end tell
end if
end repeat
on error
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try
tell application "Finder"
shut down
end tell
...That's it... Save these two scripts as apps, give them an icon, put them in your dock and in two clicks you clean and shutdown your mac!
Cheers! (Still searching to do it in one click though!)
Joe D.
Here's the first script to startup CCleaner and run the cleaning process:
tell application "CCleaner"
activate
tell application "System Events"
click button "Run Cleaner" of window "Ccleaner" of process "CCleaner"
end tell
end tell
And here is the other script, to shut down all apps and shutdown the Mac:
tell application "System Events" to set the visible of every process to true
set white_list to {"Finder"}
try
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
set this_process to item i of the process_list
if this_process is not in white_list then
tell application this_process
quit
end tell
end if
end repeat
on error
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try
tell application "Finder"
shut down
end tell
...That's it... Save these two scripts as apps, give them an icon, put them in your dock and in two clicks you clean and shutdown your mac!
Cheers! (Still searching to do it in one click though!)
Joe D.
#6 OFFLINE
Posted 01 June 2012 - 07:51 AM
Still searching...
Now, I'm checking another forum (the cool macscripter.net) to see if it's possible to determine in my script whether CCleaner has done its task yet. I'm still working on it, but the main idea is to let the script check every x seconds since CCleaner started cleaning to see if the average(!) processor (CPU) usage of CCleaner hasn't dropped below a certain percentage yet (for instance 8%). If so, CCleaner will be told to quit. If not, the script will continue checking.
If (I don't know yet, so bear with me!) and when it works, I'll post about it! And I'll post the script(s) of course!
Cheers,
Joe D.
Now, I'm checking another forum (the cool macscripter.net) to see if it's possible to determine in my script whether CCleaner has done its task yet. I'm still working on it, but the main idea is to let the script check every x seconds since CCleaner started cleaning to see if the average(!) processor (CPU) usage of CCleaner hasn't dropped below a certain percentage yet (for instance 8%). If so, CCleaner will be told to quit. If not, the script will continue checking.
If (I don't know yet, so bear with me!) and when it works, I'll post about it! And I'll post the script(s) of course!
Cheers,
Joe D.
#7 OFFLINE
Posted 01 June 2012 - 11:37 AM
Success!
Only, not with the average CPU usage, but the script determines whether the CPU usage goes at least 3 times under 40 %. These numbers can be altered in the script of course to suit your needs. Experiment!
Here's the script that:
1) runs CCleaner
2) runs its cleaning task
3) quits CCleaner!
tell application "CCleaner"
activate
tell application "System Events"
click button "Run Cleaner" of window "Ccleaner" of process "CCleaner"
end tell
end tell
global idleTime, processName, averageCPUvalue, tempCPUsum, counterTics, maxCPUusage
set idleTime to 1
set processName to "CCleaner"
set counterTics to 0
set maxCPUusage to 40
on idle
set processProcessorUsage to word 2 of (do shell script "/bin/ps -xcro command,%cpu | grep " & quoted form of processName)
if processProcessorUsage < maxCPUusage then
set counterTics to counterTics + 1
if counterTics > 2 then
tell application "CCleaner"
quit
end tell
quit me
else
return idleTime
end if
else
return idleTime
end if
end idle
...Copy and paste this in Apple script editor, save it as a 'stay open' application. That's it. Whenever you run the application it will do as mentioned: start, run and quit CCleaner, in that order! Of course, you have to set CCleaner's settings (determine what it will delete) by running it manually (not with the script!) and tick the necessary boxes!
Cheers!
Joe D.
Only, not with the average CPU usage, but the script determines whether the CPU usage goes at least 3 times under 40 %. These numbers can be altered in the script of course to suit your needs. Experiment!
Here's the script that:
1) runs CCleaner
2) runs its cleaning task
3) quits CCleaner!
tell application "CCleaner"
activate
tell application "System Events"
click button "Run Cleaner" of window "Ccleaner" of process "CCleaner"
end tell
end tell
global idleTime, processName, averageCPUvalue, tempCPUsum, counterTics, maxCPUusage
set idleTime to 1
set processName to "CCleaner"
set counterTics to 0
set maxCPUusage to 40
on idle
set processProcessorUsage to word 2 of (do shell script "/bin/ps -xcro command,%cpu | grep " & quoted form of processName)
if processProcessorUsage < maxCPUusage then
set counterTics to counterTics + 1
if counterTics > 2 then
tell application "CCleaner"
quit
end tell
quit me
else
return idleTime
end if
else
return idleTime
end if
end idle
...Copy and paste this in Apple script editor, save it as a 'stay open' application. That's it. Whenever you run the application it will do as mentioned: start, run and quit CCleaner, in that order! Of course, you have to set CCleaner's settings (determine what it will delete) by running it manually (not with the script!) and tick the necessary boxes!
Cheers!
Joe D.
#8 OFFLINE
Posted 01 June 2012 - 02:36 PM
Awesome thanks, I hope the developers add this feature, but your script (much like Alan_B's Batch files will make great use for advanced users until such time.
ADVICE FOR USING CCleaner'S REGISTRY INTEGRITY SECTION
DON'T JUST CLEAN EVERYTHING THAT'S CHECKED OFF.
Do your Registry Cleaning in small bits (at the very least Check-mark by Check-mark)
ALWAYS BACKUP THE ENTRY, YOU NEVER KNOW WHAT YOU'LL BREAK IF YOU DON'T.
CCLEANER, RECUVA, DEFRAGGLER AND SPECCY DOCUMENTATION CAN BE FOUND AT www.piriform.com/docs
Link to Winapp2.ini explanation
DON'T JUST CLEAN EVERYTHING THAT'S CHECKED OFF.
Do your Registry Cleaning in small bits (at the very least Check-mark by Check-mark)
ALWAYS BACKUP THE ENTRY, YOU NEVER KNOW WHAT YOU'LL BREAK IF YOU DON'T.
CCLEANER, RECUVA, DEFRAGGLER AND SPECCY DOCUMENTATION CAN BE FOUND AT www.piriform.com/docs
Link to Winapp2.ini explanation










