Jump to content

Detect if already running


SkiFreak
 Share

Recommended Posts

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?

Link to comment
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."

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

Edited by Cookie
Link to comment
Share on other sites

  • Moderators

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.

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

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

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