AutoHotkey Community

It is currently May 26th, 2012, 1:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: December 24th, 2007, 9:03 pm 
Offline

Joined: February 24th, 2007, 6:02 pm
Posts: 175
Location: Budapest, Hungary
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 24th, 2007, 9:13 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1933
Location: Germany
A check based on the PID would make more sense to me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 24th, 2007, 9:17 pm 
Offline

Joined: February 24th, 2007, 6:02 pm
Posts: 175
Location: Budapest, Hungary
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 24th, 2007, 9:25 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1933
Location: Germany
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2007, 1:31 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group