| View previous topic :: View next topic |
| Author |
Message |
HuBa
Joined: 24 Feb 2007 Posts: 172 Location: Budapest, Hungary
|
Posted: Mon Dec 24, 2007 9:03 pm Post subject: #SingleInstance, filename check |
|
|
I suppose the #SingleInstance condition is evaluated against the script's full path.
Now my problem is that my script directory can be accessed from various ways.
I use subst to map a dir as a drive and also a local network share.
For example a D drive linking to C:\Dev
C:\Dev\AHK source\MyScript.ahk
D:\AHK source\MyScript.ahk
MyScript.ahk is physically the same.
I can launch a script from either way but it will start as a new instance even if I specified the "#SingleInstance force" flag, because the path for the filename is different and AHK believes that they are different files.
So I suggest an instance check considering only the filename without the directory path.
Maybe an option for the #SingleInstance directive. |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 384 Location: Berlin
|
Posted: Mon Dec 24, 2007 9:13 pm Post subject: |
|
|
| A check based on the PID would make more sense to me. |
|
| Back to top |
|
 |
HuBa
Joined: 24 Feb 2007 Posts: 172 Location: Budapest, Hungary
|
Posted: Mon Dec 24, 2007 9:17 pm Post subject: |
|
|
| Tuncay wrote: | | A check based on the PID would make more sense to me. |
You misunderstood it. The ProcessID cannot help here.
I want to start the same script from different locations and I want to be sure there is only one instance running. |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 384 Location: Berlin
|
Posted: Mon Dec 24, 2007 9:25 pm Post subject: |
|
|
| Why cannot the PID help? The PID is the identity from all windows processes. You should not forget, that others could name the script exactly you did. Why not changing the command to use PID? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Thu Dec 27, 2007 1:31 pm Post subject: |
|
|
You have to use some other way to achieve that. Although your wish is semanticaly correct, when processes are in question it isn't a practice.
Generaly, u must use Mutex to achieve that.
My suggestion - on startup, you BROADCAST the message that only your running instnace can respond. That way you don't need to know hwnd or anything, so it can even be used for totaly different scripts if you don't want them to be run in paralel. If you don't get response that means there is no instance running. If you get the response, you will also get the hwnd of the responder in which case you can direct it to shutdown, or you can kill it and run normaly.
Only other way to check if script is the same as some other script is to use checksum, and that will slowdown startup a lot. _________________
 |
|
| Back to top |
|
 |
|