Sign in to follow this  
Followers 0
dooshorama

Req: 1 Instance Only

3 posts in this topic

it is too bad autoit 2.64 is no longer in developement. i would have liked to see this addition to it:

support for running only 1 instance of a script. my suggestion:

make a command called "setinstance". it can be set to:

0 : unlimited, the script can be executed many times (current behaviour)

1 : only 1 instance allowed; the new instance will not execute

2 : only 1 instance allowed; old instance killed, new instance started

example: setinstance,1

as to what makes 2 scripts the same.. either filename, or simple checksum.

too complex ? v2.65 ? :whistle:

Share this post


Link to post
Share on other sites



You can do that in a script. This code may not be correct, I haven't use 2.xx in over a year, but something along the lines of:

IfWinExists, MyAutoItWindowTitle, Exit
AutoItSetTitle, MyAutoItWindowTitle

The syntax and/or names of those methods may be wrong, but the basic idea is, look for a specific window title, if it is found, exit. If it's not found, then that means another instance of your script isn't running, so set the script's title to that name you searched for. That way, if a second instance attempts to run, it'll find the window title of the first, know it's running and abort.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

i used:

ifwinexist,AutoIt-myscript,,exit

winsettitle,AutoIt v2.6,,AutoIt-myscript

this will only work under the following conditions:

1) autoit window is not minimized

2) there is only 1 window titled "AutoIt v2.6"

:D:huh2:

Edited by dooshorama

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0