murdock Posted February 15, 2008 Share Posted February 15, 2008 I saw the question a day or two ago, and I meant to copy down the answer and I forgot >.< Ive been searching through the forum but I cant find the thread. I just want to have my script close any other instances of itself when its ran, thats all. Link to comment Share on other sites More sharing options...
Monamo Posted February 15, 2008 Share Posted February 15, 2008 I saw the question a day or two ago, and I meant to copy down the answer and I forgot >.<Ive been searching through the forum but I cant find the thread.I just want to have my script close any other instances of itself when its ran, thats all.A popular solution is _Singleton() - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
murdock Posted February 15, 2008 Author Share Posted February 15, 2008 Im not sure that will work after I compile the script? Will it work with the .exe also? Link to comment Share on other sites More sharing options...
NELyon Posted February 15, 2008 Share Posted February 15, 2008 (edited) Im not sure that will work after I compile the script? Will it work with the .exe also? Untested ;Put at beginning of script If ProcessExist(@ScriptName) Then Exit EndIf ;Rest of code EDIT: MUST be compiled Edited February 15, 2008 by Senton-Bomb Link to comment Share on other sites More sharing options...
Developers Jos Posted February 15, 2008 Developers Share Posted February 15, 2008 (edited) Im not sure that will work after I compile the script?Will it work with the .exe also?Whats the doubts you have ?Pretty sure it works because what else would this UDF be useful for ?Jos Edited February 15, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SpookMeister Posted February 15, 2008 Share Posted February 15, 2008 From the FAQ in the helpfile14. How can I make sure only one copy of my script is run?The easiest way is to rename the title of the hidden AutoIt window when your script first starts. Then in the same script check for that window title existing - if it does then another copy of the script is running.; Place at the top of your script$g_szVersion = "My Script 1.1"If WinExists($g_szVersion) Then Exit ; It's already runningAutoItWinSetTitle($g_szVersion); Rest of your script goes here [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] 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