Sign in to follow this  
Followers 0
FengHuangWuShen

Single Instance Script

6 posts in this topic

#1 ·  Posted (edited)

#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



#2 ·  Posted (edited)

#include <Misc.au3>
_singleton()

 

Edited by AndyG

Share this post


Link to post
Share on other sites

#3 ·  Posted

@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!

Share this post


Link to post
Share on other sites

#4 ·  Posted

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

#5 ·  Posted

^^^^^^Information that would have been great in your first post...


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

Share this post


Link to post
Share on other sites

#6 ·  Posted

True :P My bad

1 person likes this

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