Jump to content

Single Instance Script


Recommended Posts

#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
Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...