Jump to content
Sign in to follow this  
FengHuangWuShen

Single Instance Script

Recommended Posts

FengHuangWuShen
#Include <Process.au3>

Func Instance_Check()
    Local $PROCESS_COUNT = 0
    Local $PROCESS_LIST = ProcessList('SomePrcoess.exe')
    For $i = 1 To $PROCESS_LIST[0][0]
        $PROCESS_COUNT = $PROCESS_COUNT + 1
    Next
    If $PROCESS_COUNT > 1 Then
        Exit
        ;MsgBox(0, 'DEBUG - Failed!', 'Multi-insatance.')
    Else
        MsgBox(0, 'DEBUG - Success!', 'One instance.')
    EndIf
EndFunc

 

Edited by FengHuangWuShen

Share this post


Link to post
Share on other sites
AndyG
#include <Misc.au3>
_singleton()

 

Edited by AndyG

Share this post


Link to post
Share on other sites
JLogan3o13

@FengHuangWuShen if this was meant as an Example, actually explaining why it is useful would be awesome, rather than just posting a code block - especially an explanation on how this would be better than using _Singleton() as is suggested above.

If you're trying to use the code block and having problems, again an actual description would be a lot better than simply posting a block of code and asking everyone to guess.


√-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
FengHuangWuShen

The singleton function just seemed really large, and the code above seems to achieve the same thing. I was just thinking it was a different way to go about it I guess, and if anyone who is new to autoit like myself, they could see an easy example of how I came to make it work.

Share this post


Link to post
Share on other sites
FengHuangWuShen

True :P My bad

  • Like 1

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  

×