<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Run only one copy of an application</title>
	<atom:link href="http://huddledmasses.org/run-only-one-copy-of-an-application/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org/run-only-one-copy-of-an-application/</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Mon, 15 Mar 2010 20:36:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-172699</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Thu, 10 Jul 2008 12:50:10 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-172699</guid>
		<description>Oh, I see what you mean … you’re trying to run … only two. Or rather, only one _that you started_.  I didn’t understand what you meant at all. 

Obviously having RunOnlyOne track what it starts should work fine (or, I take it, *does* work fine for you) ... I mean, it’s hypothetically possible that you could get a coincidence with the process id on a subsequent boot or something, but it seems really unlikely.

Sorry for the confusion.</description>
		<content:encoded><![CDATA[<p>Oh, I see what you mean … you’re trying to run … only two. Or rather, only one <em>that you started</em>.  I didn’t understand what you meant at all. </p>
<p>Obviously having RunOnlyOne track what it starts should work fine (or, I take it, <strong>does</strong> work fine for you) ... I mean, it’s hypothetically possible that you could get a coincidence with the process id on a subsequent boot or something, but it seems really unlikely.</p>
<p>Sorry for the confusion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-172536</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 10 Jul 2008 02:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-172536</guid>
		<description>Actually I did read the article (no need to be pissy).  I also tried the proc parameter and it doesn&#039;t work properly with &quot;Explorer.exe&quot; as there is always an instance running, so it will not bring up a window initially when used with &quot;proc&quot;.

In order to make it work I had to change the code and have it store the process id in the registry.  It will try to find that process id running and switch to it.  If it&#039;s not valid or another named process is in its place it spawns a new instance and updates the id in the registry.

With that change and a change to how the focus is reset, it works fine.</description>
		<content:encoded><![CDATA[<p>Actually I did read the article (no need to be pissy).  I also tried the proc parameter and it doesn&#8217;t work properly with &#8220;Explorer.exe&#8221; as there is always an instance running, so it will not bring up a window initially when used with &#8220;proc&#8221;.</p>
<p>In order to make it work I had to change the code and have it store the process id in the registry.  It will try to find that process id running and switch to it.  If it&#8217;s not valid or another named process is in its place it spawns a new instance and updates the id in the registry.</p>
<p>With that change and a change to how the focus is reset, it works fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-158248</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Wed, 21 May 2008 17:00:29 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-158248</guid>
		<description>Sorry, did you even read the article? It matches based on process name, not window titles.  That&#039;s why it has a -proc parameter.</description>
		<content:encoded><![CDATA[<p>Sorry, did you even read the article? It matches based on process name, not window titles.  That&#8217;s why it has a -proc parameter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-157586</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Sun, 18 May 2008 23:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-157586</guid>
		<description>Joel, I was looking for something like this to be able to hotkey an Explorer window to open to a specific directory or to switch back to the explorer window if it was currently open (regardless of the directory I left it at). The problem with RunOnlyOne is that I believe explorer changes the name of the Window each time the directory changes.  If this is the case, the only way I could see RunOnlyOne working is if it tracked the process id instead of the name?

Does this sound like it could work, or maybe there&#039;s just a better way to do what I&#039;m wanting. 

Thanks
-Doug</description>
		<content:encoded><![CDATA[<p>Joel, I was looking for something like this to be able to hotkey an Explorer window to open to a specific directory or to switch back to the explorer window if it was currently open (regardless of the directory I left it at). The problem with RunOnlyOne is that I believe explorer changes the name of the Window each time the directory changes.  If this is the case, the only way I could see RunOnlyOne working is if it tracked the process id instead of the name?</p>
<p>Does this sound like it could work, or maybe there&#8217;s just a better way to do what I&#8217;m wanting. </p>
<p>Thanks<br />
-Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-141725</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Sat, 09 Feb 2008 05:01:40 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-141725</guid>
		<description>Actually, it should not be a Vista only app, but it probably does require the latest VC++ 8 runtime dlls... I&#039;ll make sure I include them in the update...</description>
		<content:encoded><![CDATA[<p>Actually, it should not be a Vista only app, but it probably does require the latest VC++ 8 runtime dlls&#8230; I&#8217;ll make sure I include them in the update&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-141213</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Tue, 05 Feb 2008 23:22:42 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-141213</guid>
		<description>The program seems to get the error:
&quot;This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.&quot;

Is this a Vista only app?  Did now know if there was a dll or such that xp does not have.

Best Regards,
-daniel</description>
		<content:encoded><![CDATA[<p>The program seems to get the error:<br />
&#8220;This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.&#8221;</p>
<p>Is this a Vista only app?  Did now know if there was a dll or such that xp does not have.</p>
<p>Best Regards,<br />
-daniel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JF</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-140351</link>
		<dc:creator>JF</dc:creator>
		<pubDate>Thu, 31 Jan 2008 15:51:23 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-140351</guid>
		<description>Actually, after a little more playing, I discovered what I think is the &#039;right way&#039;.  Apparently SwitchToApplication messes with the Z-ordering  of any applications between the currently focused app, and the app you wish to switch to - like the way Alt-Tab brings each window into focus as you tab through them.  Furthermore, if the window is maximized and focused, and you RunOnlyOne again, it shouldn&#039;t restore the window.  Anyway, I think I&#039;ve fixed all possible scenarios and have been running the new code and haven&#039;t detected any bugs:

//add these lines over the process iteration loop
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);

// replace SwitchToThisWindow() with:

::GetWindowPlacement( itw.First(), &amp;wp);
if( wp.showCmd == SW_SHOWMINIMIZED ) {
	::ShowWindow( itw.First(), SW_RESTORE );
} else {
	::SetForegroundWindow( itw.First() );
}</description>
		<content:encoded><![CDATA[<p>Actually, after a little more playing, I discovered what I think is the &#8216;right way&#8217;.  Apparently SwitchToApplication messes with the Z-ordering  of any applications between the currently focused app, and the app you wish to switch to &#8211; like the way Alt-Tab brings each window into focus as you tab through them.  Furthermore, if the window is maximized and focused, and you RunOnlyOne again, it shouldn&#8217;t restore the window.  Anyway, I think I&#8217;ve fixed all possible scenarios and have been running the new code and haven&#8217;t detected any bugs:</p>
<p>//add these lines over the process iteration loop<br />
<span class="caps">WINDOWPLACEMENT</span> wp;<br />
wp.length = sizeof(wp);</p>
<p>// replace SwitchToThisWindow() with:</p>
<p>::GetWindowPlacement( itw.First(), &amp;wp);<br />
if( wp.showCmd == SW_SHOWMINIMIZED ) {<br />
	::ShowWindow( itw.First(), SW_RESTORE );<br />
} else {<br />
	::SetForegroundWindow( itw.First() );<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel 'Jaykul' Bennett</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-140271</link>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
		<pubDate>Thu, 31 Jan 2008 05:16:20 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-140271</guid>
		<description>Yeah, absolutely... gimme a day or two and I&#039;ll repost the new one</description>
		<content:encoded><![CDATA[<p>Yeah, absolutely&#8230; gimme a day or two and I&#8217;ll repost the new one</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JF</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-140219</link>
		<dc:creator>JF</dc:creator>
		<pubDate>Wed, 30 Jan 2008 23:24:40 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-140219</guid>
		<description>Actually I just played around with this with VS 2008 Express (as in free).  All that is needed is:

::ShowWindow(itw.First(), SW_SHOWNORMAL);

works like a champ.  Perfect for use with cygwin.</description>
		<content:encoded><![CDATA[<p>Actually I just played around with this with VS 2008 Express (as in free).  All that is needed is:</p>
<p>::ShowWindow(itw.First(), SW_SHOWNORMAL);</p>
<p>works like a champ.  Perfect for use with cygwin.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JF</title>
		<link>http://huddledmasses.org/run-only-one-copy-of-an-application/comment-page-1/#comment-140190</link>
		<dc:creator>JF</dc:creator>
		<pubDate>Wed, 30 Jan 2008 21:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/run-only-one-copy-of-an-application/#comment-140190</guid>
		<description>KH&gt;  I&#039;m not really a C coder, but I think you would just need add these lines:

::ShowWindow(itw.First(), SW_SHOWNORMAL);
::BringWindowToTop(itw.First());

right after the SwitchToWindow line...that would restore the window if it&#039;s minimized, as well as bring the window to top if it&#039;s open but behind some other window(s).
 
Joel - do you think you could update the code &amp; binary to include the changes?</description>
		<content:encoded><![CDATA[<p>KH&gt;  I&#8217;m not really a C coder, but I think you would just need add these lines:</p>
<p>::ShowWindow(itw.First(), SW_SHOWNORMAL);<br />
::BringWindowToTop(itw.First());</p>
<p>right after the SwitchToWindow line&#8230;that would restore the window if it&#8217;s minimized, as well as bring the window to top if it&#8217;s open but behind some other window(s).</p>
<p>Joel &#8211; do you think you could update the code &amp; binary to include the changes?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
