Sign in to follow this  
Followers 0
Jac

Cpu at 50%

9 posts in this topic

Here is the code im running on my pc
 
I juste want to check if the program yyy.exe is running 
 
If not im killing program xxx.exe
 
It's alway running at 50% on my vm
 
Is it normal ? 
 
 
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..Program Files (x86)AutoIt3Iconsau3script_v10.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
 
 AutoIt Version: 3.3.12.0
 Author:         myName
 
 Script Function:
Template AutoIt script.
 
#ce ----------------------------------------------------------------------------
 
; Script Start - Add your code below here
 
 
While 1
If Not ProcessExists("xxx.exe") Then
ProcessClose("yyy.exe")
MsgBox(0,"info","xxx Not Running.  Closing yyy")
Exit
Else
If Not ProcessExists("yyy.exe") Then Run("C:Program Files (x86)xxxxxx.exe","C:Program Files (x86)xxx")
EndIf
WEnd
Else
MsgBox($MB_ICONERROR, "", "Launch xxx")
 
EndIf
 
 
Thanks !
 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Add a short sleep, like 100ms, to keep your While loop from being so CPU intensive.

Edited by JLogan3o13
2 people like this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

your code is breacking my head ... rly... i dont get the conditional position...

The Wend position is strange ..

it s like there is two way to get the else stat i rly dont get it ... lol

 

you even can do a while of 1 or 2 seconde ... sleep (1000) or (2000) as you usualy need to save memory and CPU on a VM

Edited by caramen

Share this post


Link to post
Share on other sites

Jac,

See my sig for how to post code.

Your code as posted generates the following when run through Au3Check...

>"C:Program Files (x86)AutoIt3SciTEtidytidy.exe" "C:UsersADMIN010Documentsbb.au3"
Tidy AutoIt3 v14.801.1932.0   Copyright © Jos van der Zande  August 01,2014
"C:UsersADMIN010Documentsbb.au3"(28) : ### Tidy Error: "else" is likely missing it's opening statement. next line creates a negative tablevel.
"C:UsersADMIN010Documentsbb.au3"(31) : ### Tidy Error: "endif" is likely missing it's opening statement. next line creates a negative tablevel.
!> there were  2 error(s) encountered. look in your source for:### Tidy Error:
+> Tidy AutoIt3 finished. Original copied to:"C:UsersADMIN010DocumentsBackUpbb_old3.au3"
>Exit code: 2    Time: 1.53

 

The code also seems illogical.  If XXX is running and YYY is not you will run instances of XXX continuously.  You also need a Sleep somewhere to idle the processor.

If you can define what you are trying to do maybe we can help.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

What your code does:

:begin

IF xxx.exe is not running,

THEN blindly close yyy.exe (which may or may not be running) and exit

ELSE (note: xxx.exe is running!): if yyy.exe is not running, then start xxx.exe

goto :begin

(and then here some unreachable code which is never executed)

In other words, as long as xxx.exe is running and yyy.exe is not running, start another instance of xxx.exe.

In yet other words: if yyy.exe is not running, you are starting addidional instances of xxx.exe as fast as your computer can handle. That must be why your CPU is boiling over. Check your task manager to confirm.

Still, it's hard to guess what you're actually aiming to accomplish with this script, and also it has unreachable code under the WEnd. Did you mean it to be active continuously or just to run it once? Please explain a bit more about the situation you're facing.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

:thumbsup: @SadBunny - nice paraphrase of my post (right above yours)...

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

:thumbsup: @SadBunny - nice paraphrase of my post (right above yours)...

 

Ah, right... Missed the fact that you wrote a bunch of stuff under that quote  :sweating:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

No worries, just poking fun.   I enjoy reading your concise explanations :lol:


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

No worries, just poking fun.   I enjoy reading your concise explanations :lol:

 

At work they call me Sad -vvv Bunny.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

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  
Followers 0