Jump to content

unexpected cpu usage of target programs called in AutoIt script


Recommended Posts

I made a script like the following:

Run("ProgA.exe")
While 1
    sleep(20)
    If ProcessExists("ProgA.exe") = 0 Then
        ProcessClose("ProgB.exe")
        Exit
    ElseIf WinActive("ProgA") Then
        ( let ProgA)  do "somethings"
    EndIf
WEnd

When I run it, everything work fine. But there is a problem:

When I click the mouse to any other program than ProgA, then the windows of ProgA is not active.

But in taskmanager, I found that ProgA.exe still use 1%~2% cpu. If I change the sleep timer smaller in "somethings", then ProgA.exe use more cpu. It's weired because when the window of ProgA is not activate, then ProgA will do nothing? Do I miss something?

Link to comment
Share on other sites

well did you code programA to work only if it main win state is active?

your missing that script still check if win is active and if process exsist

on the other hand i whud do loop probably like this

While 1
    sleep(20)
    Select
        Case WinActive("ProgA")
            ;let ProgA do somethings
        Case ProcessExists("ProgB.exe")
            If Not ProcessExists("ProgA.exe") Then
                ProcessClose("ProgB.exe")
                Exit
            EndIf
    EndSelect
WEnd
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...