Sign in to follow this  
Followers 0
SkiFreak

Detect if already running

11 posts in this topic

Is there a way to have the application (a compiled AutoIt script) detect if it already running?

Using ProcessExists is not an option as it will always detect itself when started. :)

I need to be able to ensure that there is only ever one instance of the application running at any one time.

A bit more info:

As might have been seen from my previous post, I am running a continuous loop and checking for changes in a file. There is no "window" that I can check for, the only thing that identifies that the application is running is that there is a tray icon.

Is this possible?

Share this post


Link to post
Share on other sites



Seek and ye shall find (sometimes).

Next time I guess that I will have to look a little bit harder.

Thanks for showing me the light at the end of the tunnel...

Share this post


Link to post
Share on other sites

Is there a way to have the application (a compiled AutoIt script) detect if it already running?

Using ProcessExists is not an option as it will always detect itself when started. :lmao:

I need to be able to ensure that there is only ever one instance of the application running at any one time.

A bit more info:

As might have been seen from my previous post, I am running a continuous loop and checking for changes in a file. There is no "window" that I can check for, the only thing that identifies that the application is running is that there is a tray icon.

Is this possible?

Hello ..have you looked at Singleton :">

;Singleton - To check to see that App runs once only

#include <Misc.au3>

Singleton("123456789");Create a unique value

Func Singleton($semaphore)

Local $ERROR_ALREADY_EXISTS = 183

DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $semaphore)

Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")

If $lastError[0] = $ERROR_ALREADY_EXISTS Then

MsgBox(48, "What again....??", "The software is already running.... Dummy!! ");Error message

Exit -1

EndIf

EndFunc ;Singleton end


"Our deepest fear is not that we are inadequate.Our deepest fear is that we are powerful beyond measure.It is our light, not our darkness that most frightens us."

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This works for me

If WinExist("Program_name")

MsgBox(0, "Error", "Program already running")

Exit

Endif

GuiCreate("Progam_name",100,100)

Program_name is the name where you create the gui with

Edited by Cookie

Share this post


Link to post
Share on other sites

This works for me

If WinExist("Program_name")

MsgBox(0, "Error", "Program already running")

Exit

Endif

GuiCreate("Progam_name",100,100)

Program_name is the name where you create the gui with

If the end-user changes your .exe name to something common, you'll run into an issue there. _SingleTon() is probably the best option here.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

If the end-user changes your .exe name to something common, you'll run into an issue there. _SingleTon() is probably the best option here.

... as opposed to a _TwoTon() function ...

Who else would I be?

Share this post


Link to post
Share on other sites

... as opposed to a _TwoTon() function ...

Wouldnt that be _DoubleTon()? :lmao:

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Arrrrgh... Yes it would.


Who else would I be?

Share this post


Link to post
Share on other sites

Arrrrgh... Yes it would.

hehe... but I generally pun the same way :lmao:

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Why not use the AutoIt window? Set it in a way that no other window could possibly do the same thing. Something like "fhvhjbhdsbcjkndhvbhjvggahkhdhfbrhvbh"? Just use the window AutoIt always makes if your script has none.

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