JonnyThunder Posted March 25, 2008 Share Posted March 25, 2008 Hello, I saw this already - but a search didn't show it up. How can I check if the current script is already running so that I don't have two instances of the same script running on a PC? Link to comment Share on other sites More sharing options...
the1venom Posted March 25, 2008 Share Posted March 25, 2008 usually there is an icon in the systemtray for every running script Link to comment Share on other sites More sharing options...
JonnyThunder Posted March 25, 2008 Author Share Posted March 25, 2008 Yeah, there is - but I want to check if the script is already running (on startup) so that I can exit the script if an instance is found. I know there's a simple way to do it - I read it here before. Just can't find it again. Link to comment Share on other sites More sharing options...
covaks Posted March 25, 2008 Share Posted March 25, 2008 Q3 in the FAQ Link to comment Share on other sites More sharing options...
JonnyThunder Posted March 25, 2008 Author Share Posted March 25, 2008 OMG - I knew i'd seen it somewhere! Thanks very much. Link to comment Share on other sites More sharing options...
DarkMatter Posted March 25, 2008 Share Posted March 25, 2008 (edited) Hello, I saw this already - but a search didn't show it up. How can I check if the current script is already running so that I don't have two instances of the same script running on a PC? If you look at the Misc.au3 UDF there is a function called _Singleton that does just that. Example: If _Singleton($sOccurenceName, 1) = 0 Then MsgBox(16, "Error", Another instance of this program is already running.") Exit EndIf You can just type in _Signleton in the index portion of the helpfile and it will also tell you how to use it. (Sorry in the middle of me typing this post I see that someone else has posted this. Sorry for the repeat.) Edited March 25, 2008 by MattWise [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
JonnyThunder Posted March 25, 2008 Author Share Posted March 25, 2008 I can't actually get _Singleton to work. It says the script is already running even for the first instance. Am I right in saying that if I compile my script as "test.exe" then I should be using this.... If _Singleton("test.exe", 1) Then MsgBox(0, "Error", "Script is already running") Exit Endif That isn't working for me. Link to comment Share on other sites More sharing options...
DarkMatter Posted March 25, 2008 Share Posted March 25, 2008 Should be: If _Singleton("test.exe", 1) = 0 Then MsgBox(0, "Error", "Script is already running") Exit Endif Your checking to see if it equals true, you should check to see if it equals false. [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
JonnyThunder Posted March 25, 2008 Author Share Posted March 25, 2008 Once again, thank you. It seems i'm in 'schoolboy error hell' today. Link to comment Share on other sites More sharing options...
DarkMatter Posted March 25, 2008 Share Posted March 25, 2008 Once again, thank you.It seems i'm in 'schoolboy error hell' today. No problem. That's what we are here for [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now