Jump to content

Recommended Posts

Posted

I have even taken the exact example from the manual and it still is not working. Every time it lets more copies run and the example keeps saying it is the first occurrence. Am I doing something wrong? I mean I even copied the example code to a new file without any change and still it is not working as I expect it to. I have used singleton more times than I can count without error but now  I cannot get it to work at all.

I would appreciate some help with this.

Posted

Can you give some more info

  • Windows Version ?
  • AutoIt Version ?
  • smallest Repro

 

mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Windows 7 x64 Pro

v3.3.10.2

Smallest what?

If I take the exact example from the help file for _Singleton and compile it and run it on my computer and leave the message box open it keeps running more and more and more. I give it to a friend and it works fine and warns that there is another copy already running. If this is not consistent then how can I rely on it? I am trying to write something important for someone and now I have no idea what to do.

Posted

I checked this on my

Windows 7 x64 Pro
v3.3.10.2

and

v3.3.12.0

 

For me it works well.

I have a question:

Do you run two times the same EXE file in the same way?

Or maybe once you run the EXE and once from the SciTE by using the F5 key.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

same issue, no idea what the problem is, there are a couple of threads where the solution is provide to just:  processlist, if your scriptname.exe is in that array then exit.  I've used that for years.

  Reveal hidden contents

Posted

I asked to be sure what were the conditions of the test.
At the moment I have no idea what could be the cause.

You have to wait for the response of other members.

mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Look in my signature for _SingletonPID(). This does exactly the same thing and works.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 6/20/2014 at 2:40 AM, boththose said:

same issue, no idea what the problem is, there are a couple of threads where the solution is provide to just:  processlist, if your scriptname.exe is in that array then exit.  I've used that for years.

What happens if I just copy the exe and rename it? Try it yourself.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Its not useful to fight it when there are reasonable alternatives, but I do think there are enough threads to say there is an issue, and the issue is the function is unreliable.  A year ago I would have maybe submitted a bug report, now I would just lobby for its removal.

Edit:  Unless there a debug version of singleton you could throw together? At least then it is not the eternally frustrating 'works on my machine' debacle.

Edited by boththose

  Reveal hidden contents

Posted (edited)

Well I first would ask Morthawt to add a console write line with @error placed in between to see what error is returned (if any).

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

stole this from somewhere, its what i use at the top, I'll drag out my old machine that it never worked on and let you know the @error

$p = ProcessList(StringReplace(@ScriptName,".au3",".exe"))
If $p[0][0] > 1 Then
    MsgBox(0,"Error", @ScriptName & " is already running! Exiting...", 3)
    Exit
EndIf
Edited by boththose

  Reveal hidden contents

Posted

That's not full proof by the way as I mentioned above.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

iif you need not to alow starting it more than once

If WinExists("autoit win") Then Exit MsgBox(0, AutoItWinGetTitle(), 'Already running, we will now exit')
AutoItWinSetTitle("autoit win")
MsgBox(0, AutoItWinGetTitle(), 'Im Alive')
if you need to exit older instance gracefully then listen to guinness i guess :P Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

  Reveal hidden contents


460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted
  On 6/20/2014 at 2:30 PM, bogQ said:

if you need to exit older instance gracefully then listen to guinness i guess :P

Finally. -_0 People should understand that I have many function e.g. AppMonEx, _SingletonPID(), _SingltonHWID() & WM_COPYDATA that look at having a single instance of an application running. So I like to think I have some expertise in this area.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Sure but your expertise cannot explain why singleton fails in many independent tests carried out over many years.  So its awesome that you have workarounds, so do we.

In the land of unattended installations your concerns are not valid, as that edge case involves the user running my exe once, leaving it open, then unpacking the entire image changing my exe name and attempting to run it again.  I think I was fairly safe.

  Reveal hidden contents

Posted (edited)

Well I am not a mind reader. I need some error message.

As for your workaround I am going to take a stab in the dark and say that Morthawt doesn't use the same system setup as you do.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

I have two very similar machines in both hardware and software, singleton works fine on one and not on the other.  I am windiffing the autoit folders hoping to find gold.

*There is no error code, but i am finding a healthy amount of inconsistencies in the autoit directory.  I will send the file versions i return if it is reasonable to suspect autoit vs the system.

Edit for your edit:  I dont think anybody uses the same setup, which is why multiple threads about the same issue from long time users would sway me from believing it an isolated issue, and maybe tied to something we all had access to.  I admittedly had to keep an old version for production, maybe a certain version of some file is doing us a disservice.

*Looks like something from 3.3.6.1  (on Win 7 SP1 x64) , I will do further research and see if i can reproduce.

Edited by boththose

  Reveal hidden contents

Posted

Well I use 8.1 x64 and so far I haven't seen this issue with _Singleton(). I also had 7 x64 and XP SP3 at some point, and that too worked fine.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)
  On 6/20/2014 at 11:10 AM, guinness said:

Well I first would ask Morthawt to add a console write line with @error placed in between to see what error is returned (if any).

 

In both runs the @error reads 0

I only use functions that come with AutoIt because I do not like relying on third party external ones. Yes it is limiting but I just prefer it that way. If one becomes part of the AutoIt package and is an official component of the language then I use them if they are useful to me.

Edit: I updated to the latest AutoIt and Scite packages last night and I am still having the same issues.

Edited by Morthawt

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
  • Recently Browsing   0 members

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