Jump to content
CD5

how do i make a loop which checks for a prosses to be on?

Recommended Posts

hello , please excuse my lack of proper terms or any ignorance to fundemental things as i have just started using autoit and have no idea what im doing :)

i am trying to check for a prosses "msiafterburner.exe" and if its not there run it "Run(@ProgramFilesDir & "c:\program files (x86)\msi afterburner\msiafterburner.exe", "", @SW_MINIMIZE)"

and i am trying to keep it in a loop so it checks every 5 seconds and makes sure msi afterburner is on.

apon running the file attached i get           "C:\Users\admin\Desktop\test1.au3" (7) : ==> "Wend" statement with no matching "While" statement.:

 

Im not sure what exactly is wrong here so perhaps someone would be willing to explane to me what im doing wrong so i can learn how to do it right,

Thanks.

test1.au3

Share this post


Link to post
Share on other sites

thanks for the quick reply ,

the test1.au3 that should be attached is the whole script that i have got , as i said im just starting to get into scripts and coding in general.

about the path , what exactly is wrong ? would Run("c:\program files (x86)\msi afterburner\msiafterburner.exe", "", @SW_MINIMIZE) function correctly (as in removing the @ProgramFilesDir &)?

Share this post


Link to post
Share on other sites
Posted (edited)

From what I am seeing in the thread you wrote you want it to check for the MSIAfterBurner every 5 seconds. The Sleep Command pauses the loop and that will be the five seconds I'd imagine. If there is a more experienced member that can correct me if I'm wrong, be my guest :) I tested it out and it will make a MsgBox appear every 5 seconds so I think I've done it :D

Below find what I think might be the solution to your question. Try it out and come back to me if I was right or wrong.

While 1
    If ProcessExists("C:Program Files (x86)\msi afterburner\msiafterburner.exe") Then
        MsgBox(0, "", "This program is already running.")
        Sleep(5000)
    Else
        Run("C:\Program Files (x86)\msi afterburner\msiafterburner.exe")
        MsgBox(0, "", "This program wasn't running, we are starting it up right now.")
        Sleep(5000)
    EndIf
WEnd

 

Regards,

Supra

EDIT: I forgot to minimize it, you have to add the @SW_MINIMIZE yourself as I forgot. Also, I'm not sure what the directory was, so you might have to change that aswell...

Edited by supraaxdd

Share this post


Link to post
Share on other sites
11 minutes ago, supraaxdd said:

ProcessExists("C:Program Files (x86)\msi afterburner\msiafterburner.exe")

Are you sure?

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Posted (edited)
1 minute ago, Jos said:

Are you sure?

Jos

He did ask for the loop to check if the Process Exists, hence this line.

Would I be wrong here? If yes, why?

I'm trying to help in the best way I can. Please excuse my errors...

 

Regards,

Supra

Edited by supraaxdd

Share this post


Link to post
Share on other sites
Posted (edited)
2 minutes ago, Jos said:

Does a processname contain the fully qualified path?

That is the path he stated, hence my edit to change it if I'm wrong :)

EDIT: Nevermind, I found out why I'm wrong... It's only the PID or Process name WITHOUT the directory. My bad :(

Edited by supraaxdd

Share this post


Link to post
Share on other sites
Just now, Jos said:

Try to reread my question, think, search , test and then reply again. ;)

Just did, Help Files all the way :D

 

Regards,

Supra

Share this post


Link to post
Share on other sites
Posted (edited)
While 1
    If ProcessExists("msiafterburner.exe") Then
        MsgBox(0, "", "This program is already running.")
        Sleep(5000)
    Else
        Run("msiafterburner.exe")
        MsgBox(0, "", "This program wasn't running, we are starting it up right now.")
        Sleep(5000)
    EndIf
WEnd

Pretty sure it is :)

 

Edited by supraaxdd

Share this post


Link to post
Share on other sites
Posted (edited)

Close but probably still wrong. ;) 
The test for the process will be correct now, but doubt the Run() will work unless that directory is specified in the "PATH".

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

the above is working just like i wanted it to however after closeing msi afterburner the

"This program wasn't running, we are starting it up right now."

message apears but does not start the program , any suggestions?

Share this post


Link to post
Share on other sites
Just now, Jos said:

Close but probably still wrong. ;) 
The test for the process will be correct now, but doubt the Run() will work unless that directory in is the "PATH".

Jos

I'm starting to have that feeling that I have a long way to go :P

 

Here's the correct answer:

While 1
    If ProcessExists("msiafterburner.exe") Then
        MsgBox(0, "", "This program is already running.")
        Sleep(5000)
    Else
        Run("C:\Program Files (x86)\msi afterburner\msiafterburner.exe")
        MsgBox(0, "", "This program wasn't running, we are starting it up right now.")
        Sleep(5000)
    EndIf
WEnd

Sorry for my stupidity :)

 

Regards,

Supra

Share this post


Link to post
Share on other sites
1 minute ago, supraaxdd said:

Sorry for my stupidity :)

It is not about stupidity, merely taking the time to think it through...understand... and moreover TEST...   which is called in general "learning". :)

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Just now, Jos said:

It is not about stupidity, merely taking the time to think it through...understand... and moreover TEST...   which is called in general "learning". :)

Jos

Thanks for pointing out my mistakes :)

 

Regards,

Supra

Share this post


Link to post
Share on other sites

thanks for the correction , the path is correct and everything looks good however the program is still not starting , i will check the program and perhaps test the same script but on a diffrent program to make sure msi afterburner is not at fault for it not starting up.

thanks a bunch for all your support guys il post if i find anything new but scrip looks good :)

Share this post


Link to post
Share on other sites
6 minutes ago, CD5 said:

the above is working just like i wanted it to however after closeing msi afterburner the

"This program wasn't running, we are starting it up right now."

message apears but does not start the program , any suggestions?

After some further testing, I tried to do it with Steam. It works fine. Check if the MSIAfterBurner is running in the backround.

 

Regards,

Supra

Share this post


Link to post
Share on other sites
1 minute ago, CD5 said:

thanks for the correction , the path is correct and everything looks good however the program is still not starting , i will check the program and perhaps test the same script but on a diffrent program to make sure msi afterburner is not at fault for it not starting up.

thanks a bunch for all your support guys il post if i find anything new but scrip looks good :)

Did you see the afterburner in the Task Manager as a background task? Also, there could be other programs interfering with it. here is what I mean:

image.png.86870b73e4950af08699b1d50654d16a.png

All of these are Steam processes. Once I closed off the Bootstrapper, All the below programs were closed off a few seconds later BUT when the others were closing, the loop recognised the Webhelpers as STEAM and sent the message that the program was still running. Check the task manager for any programs related to the afterburner and check in the background tasks if it is running and come back to me.

 

Regards,

Supra

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

×
×
  • Create New...