Jump to content

Running one script once


Recommended Posts

  • 3 weeks later...

_Singleton()?

I get a baffling error dialog with _Singleton()

I'm trying to use a GUID in my application for unique identifier. I know it works with system mutex because I have components in other languages that have used it for years.

Anyway, it works as expected in this code

; Script Start - Add your code below here
#include <Misc.au3>
Const $ERROR_ALREADY_EXISTS = 183
If _Singleton("{5788CDF6-1E46-41CB-88D1-E27006A8B69A}",1) = 0 Then
    iF @error = $ERROR_ALREADY_EXISTS Then Exit
EndIf

While 1
WEnd

But if I try to use the same code with a different GUID in a real app, launching the second instance gives me an error dialog "-1 variable used without being declared" instead of quitting quietly

Pretty strange. I even move the #include <Misc.au3> and the _Singleton statement way up to the top of the script to avoid interaction with other includes. No joy. Same thing. -1 without being declared yadda yadda

Edit: I figured it out. It was due to OnAutoItExit() accessing variables that were never made because the script quits.

Edited by MilesAhead
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...