Jump to content
IAMK

Kill RunWait()?

Recommended Posts

IAMK

Hello,

 

My script needs to use the RunWait() function for external executables.

However, I cannot find any information on killing the process. I have tried the equivalent of what is used to kill a process which was created using Run(), but it did not work, along with a few other things.

E.g. https://www.autoitscript.com/autoit3/docs/functions/ProcessClose.htm

Share this post


Link to post
Share on other sites
JLogan3o13

@IAMK it should be pretty easy to see why - you are telling your script to...wait while the process runs. So if you have a line after that that kills the process, your script is still waiting at the previous line (like a good dog, waiting where you told it to). The easiest way to accomplish what you're after would be to simply use Run instead of RunWait, and then watch the process. Something like this:

Run("notepad.exe")

    While ProcessExists("Notepad.exe")
        Sleep(100)
        If ProcessExists("iexplore.exe") Then ProcessClose("notepad.exe")
    WEnd

Then, if your condition is true (another process, time running out, etc.) it closes the first.

Or more simply:

Run("notepad.exe")

    While Not (ProcessExists("iexplore.exe"))
        Sleep(100)
    WEnd

ProcessClose("notepad.exe")

 

Edited by JLogan3o13

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

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
IAMK

@JLogan3o13

Okay, that's a good solution. I will try that.

As for the script waiting, that is not the issue. I have a hotkey which ends my script. I am able to end the script during the RunWait(), but if I also try to kill the process which I RunWait()ed, I'm unable to. Logically, Killing the process of a RunWait() should cause the RunWait() to finish, correct?

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

×