Sign in to follow this  
Followers 0
Nikolas92

How to launch just one instance of script when selecting multiple files from Windows Explorer menu?

2 posts in this topic




#2 ·  Posted

I would start by looking in the help at the _Singleton function.

 

I don't know what the "merge" program does in the page you referenced.  But most single instance programs designed to be run from context menu in Explorer detect if there is already a primary instance running, and if so, transfers the command tail to it, then quits.  So for example if you launch EditPad7 Lite by right clicking 20 text files in Explorer, if the single instance option is checked in preferences, you should only get one copy of the Editor with 20 tabs open and a txt file in each tab.

 

If _Singleton is not fast enough you may have to do the CreateMutex calls yourself "by hand" as it is shown in  the C++ Program you referenced.  Basically the scheme is that every instance tries to create the mutex.  The one that succeeds is the "primary" instance.  All the ones that fail to create the mutex send the command tail(the command line arguments) to it, then exit.  To do this you need to use some form of IPC, or Inter-Process Communication.  There are many to choose from.  Messages, such as WM_COPYDATA, make a temp file with the data that is read by the primary instance, named memory mapped files..   on and on.  Which is "best" varies with factors unique to your application.

 

I am sure there is existing code that demonstrates the WM_COPYDATA method in AutoIt3 if you search the forums.

 

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