I need to see if an app is already running before a new instance of it is allowed to open. This seems pretty simple, but there are additional clauses...I may have other AMS apps running (unrelated to this one) so simply looking for "autorun.exe" won't do (since I wouldn't want this app not to launch because a completely different AMS app is running).
What I want to happen is:
1) Look for an instance of this application already running
2) If not, then launch it, if so...then prompt the user that there's already another instance running and offer the user the chance to terminate that instance or to cancel and close the newest attempt to launch the program.
3) Naturally, it would then need to be able to differentiate between the two (which one to close).
I've tried several ideas but all of them have drawbacks that are undesireable. Any ideas? Here's the basic code:
windows = Window.EnumerateTitles();
window_name = "MyWindowTitle";
for handle, title in windows do
result = String.Find(title, window_name, 1, false);
if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
Thanks in advance...
Protocol
What I want to happen is:
1) Look for an instance of this application already running
2) If not, then launch it, if so...then prompt the user that there's already another instance running and offer the user the chance to terminate that instance or to cancel and close the newest attempt to launch the program.
3) Naturally, it would then need to be able to differentiate between the two (which one to close).
I've tried several ideas but all of them have drawbacks that are undesireable. Any ideas? Here's the basic code:
windows = Window.EnumerateTitles();
window_name = "MyWindowTitle";
for handle, title in windows do
result = String.Find(title, window_name, 1, false);
if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
Thanks in advance...
Protocol
Comment