Sign in to follow this  
Followers 0
blakel

How do I prevent multiple instances of the script.

6 posts in this topic

I would like to prevent multiple instances of the (compiled) script from running.

The first thing I tried was

<code>

If ProcessExists(@ScriptName) <> 0 Then Exit(0)

</code>

but that kills the current process too.

Maybe if I knew the current PID.

<code>

If ProcessExists(@ScriptName) <> @ScriptPID Then Exit(0)

</code>

But that will get the last created process, probably the current instance.

I either need to test each PID or change the current process name while I check.

any ideas?

Share this post


Link to post
Share on other sites



FAQ 14

<{POST_SNAPBACK}>

It looks like this only works for scripts with windows that show up.

Share this post


Link to post
Share on other sites

No, it doesn't.

It works with all AutoIt-scripts.

Check it out and you will find out..

(It's smart to test things first, you know..)

Share this post


Link to post
Share on other sites

It looks like this only works for scripts with windows that show up.

<{POST_SNAPBACK}>

If I told you that you have about 200 open windows presently on your desktop, you probably would not believe me. But they are there. A given process can have 20 or so hidden windows.

Autoit uses a hidden window for it's process. FAQ 14 refers to this hidden window.

:lmao:

Share this post


Link to post
Share on other sites

@Just Simple, thanks for the link to the FAQ. Just what I needed

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