Jump to content

5 Line code running CPU @100%


TheCuz
 Share

Recommended Posts

While 1

If (@hour = 19) and (@min = 26) Then

run ("mslgr.bat")

Endif

sleep (30000)

WEnd

For some reason this code takes up 100% of the CPU, any ideas. I have tried putting the sleep command after the Wend, still the same thing.

Also, when I use Run ("mslgr.bat" , "c:\"), it comes up the error can not find file. I looked at the help file example and that is what I have, minus on how the window will show. It won't run it unless I launch the EXE from the same directory that the batch file is in.

Any feeback would be great.

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
Share on other sites

While 1

If (@hour = 19) and (@min = 26) Then

run ("mslgr.bat")

Endif

sleep (30000)

WEnd

For some reason this code takes up 100% of the CPU, any ideas. I have tried putting the sleep command after the Wend, still the same thing.

Also, when I use Run ("mslgr.bat" , "c:\"), it comes up the error can not find file. I looked at the help file example and that is what I have, minus on how the window will show. It won't run it unless I launch the EXE from the same directory that the batch file is in.

Any feeback would be great.

<{POST_SNAPBACK}>

My CPU usage is unaffected by your script. I suspect you are experiencing an issue related to something else.

I don't know why the batch file is not found. Is the batch file trying to use a file it can't find? If it's the batch file that is not found,

Evidently, Run does not search the the directory of the running script. Since the script is always run from the same directory as the batch file, you could use the macro @ScriptDir to concatenate the path to the batch file name. (although I don't thing this should be necessary).

EDIT: The Run test I used was flawed, so I revised my statement

Edited by phillip123adams

Phillip

Link to comment
Share on other sites

sometimes the sleep is actually the problem, mess around with the time it sleeps, i dont understand why it uses so much CPU when my alarm clock program uses almost none even when you run it multiple times

While 1
    If @HOUR = $Hour and @MIN <= $MinE and @MIN >= $MinS Then
        SoundPlay( $File )
        Sleep( $Wait * 1000 )
        $QUITAFTER = "YES"
    EndIf
    If $QUITAFTER = "YES" Then ExitLoop
WEnd

EDIT: When running the alarm it skips around at 1-5% CPU that is a lot better than your code, this is weird

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

I'll try to play around with it a little bit and see what I can find out about it.

Thanks for the tip CyberSlug, I was just using what was on the example in the help file.

I'll post what I find out :lmao:

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
Share on other sites

just a side note, I would put in something to make sure it doesn't run the bat file twice, as there are 60 seconds in a minute, and you have it sleep 30 seconds each time.

While 1

If (@hour = 19) and (@min = 26) Then

run ("mslgr.bat")

Endif

sleep (30000)

WEnd

example

While 1
If (@hour = 19) and (@min = 26) Then
;run ("mslgr.bat")
sleep(61000); sleep for 61 seconds if time hits
Endif
sleep (100); my typical wait
WEnd

test script to determine if autoit, or the bat file is the CPU hog

$hour=@hour
$min=@min+2
if @min>58 then $min=@min
tooltip("going to go off in under 2 minutes",0,0)
While 1
If (@hour = $hour) and (@min = $min) Then
msgbox(1,"Info", "Time went off",5)
tooltip("time found sleeping 61 seconds")
sleep(61000); sleep for 61 seconds if time hits
tooltip("")
Endif
sleep (1); my typical wait
WEnd

AutoIt3, the MACGYVER Pocket Knife for computers.

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...