Jump to content
Sign in to follow this  

Detach if application is idle by CPU process

Recommended Posts


Im a bit new to the Autoit world but Im trying to learn. I have started creating a script that will start our application, process a file and once that file is processed open the next one. After each file is processed I check the memory with ProcessGetStats().

Id rather not use sleep() since the time to process can range from 20sec to 2min. Is there an easy way to detect that an application is idle (CPU 0)?

I spend a some time searching and I found _ProcessListProperties()


This seems to get the information but Im not sure how to use it in an If/then situation.

If application is idle CPU O

Then process next file

Else try again later

Edit: Ug...typo on title Detect not detach. Doesn't look like I can edit that

Edited by Redrodan

Share this post

Link to post
Share on other sites

Use a loop with a very short sleep timeout (you can sleep for 1ms if you'd like - 1/1000th of a second).

;In this example, use _ProcessListProperties() or something comparable to find the value of the CPU load and assign the value to $cpuload.

While 1
    If $cpuload = 0 Then
        ;Do whatever you want to when the cpu load is 0
    Sleep(250) ;sleep for 1/4 of a second - 250ms

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this