Sign in to follow this  
Followers 0
murdock

Quick Question

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
Share on other sites

Im not sure that will work after I compile the script?

Will it work with the .exe also?

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Senton-Bomb

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

From the FAQ in the helpfile

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

AutoItWinSetTitle($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]

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