Jump to content

AutoIt and Mutex


dexto
 Share

Recommended Posts

There is function in AutoIt with a great potential it would seem.

From documentation:

#Include <Misc.au3>
_Singleton($sOccurenceName[, $iFlag = 0])

"You can place the object in a namespace by prefixing your object name with either "Global\" or "Local\". "Global\" objects combined with the flag 2 are useful in multi-user environments."

So it should look like?:

Script 1:

#Include <Misc.au3>
_Singleton("Global\test", 2)
$a = 1;
While $a
sleep(100)
Wend

Script 2:

#Include <Misc.au3>
_Singleton("Global\test", 2)
$a = 0;

Logicaly running script 2 while script 1 is running it should set $a to 0 and let the first script exit.

Not working... Where am I wrong?

Edited by dexto
Link to comment
Share on other sites

Indeed, but you can't set the variable of AutoIt from another process this way. You need to use process communication using WM_COPYDATA, SendMessage, MemoryMappedFile, etc...

I guess that the main usage of this function is to substantially identify if your process is running more than once in the case the user has renamed the filename, changed the window name, title, and more. If you need to notify your other application that another application is running you can use _SendMessage() and _WinAPI_RegisterWindowMessage() to send your own message to it notifying it about events or process communication. If you require to pass data other than integers, i.e. pointers you need to use the aforementioned process communication methods.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...