Jump to content

Recommended Posts

Posted

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?

Posted

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

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
  • Moderators
Posted

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.

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.

Posted

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?

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
×
×
  • Create New...