<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>DisplayFusion RSS: BFS.Application.GetMainWindowByAppID() not working?</title>
<atom:link href="https://www.displayfusion.com/Discussions/RSS/?TopicID=20936865-2235-4aa9-992a-ed84a4b959fa" rel="self" type="application/rss+xml" />
<link>https://www.displayfusion.com/Discussions/RSS/?TopicID=20936865-2235-4aa9-992a-ed84a4b959fa</link>
<description>DisplayFusion RSS: BFS.Application.GetMainWindowByAppID() not working?</description>
<lastBuildDate>Fri, 01 May 2026 18:54:00 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.displayfusion.com/Discussions/RSS/?TopicID=20936865-2235-4aa9-992a-ed84a4b959fa</generator>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#10</link>
<pubDate>Thu, 13 Oct 2016 18:15:39 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#10</guid>
<category>DisplayFusion</category>
<description><![CDATA[Ah yep, that makes sense. We tested with Firefox, Chrome, and Notepad++. All of those would definitely have this issue. Thanks for the update!]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Ah yep, that makes sense. We tested with Firefox, Chrome, and Notepad++. All of those would definitely have this issue. Thanks for the update!
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#9</link>
<pubDate>Thu, 13 Oct 2016 11:03:24 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#9</guid>
<category>DisplayFusion</category>
<description><![CDATA[Hi Keith,
Thanks for that! I'm not sure it's actually a DF issue given what I read yesterday though. Firefox seems to want to be a single instance no matter what you do, so even if you fire off 4 windows or tabs they all have one PID meaning all you can do is search by window title. There's a si...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hi Keith,<br/>
<br/>
Thanks for that! I'm not sure it's actually a DF issue given what I read yesterday though. Firefox seems to want to be a single instance no matter what you do, so even if you fire off 4 windows or tabs they all have one PID meaning all you can do is search by window title. There's a similar problem with Java apps like the Arduino IDE.<br/>
<br/>
Cheers<br/>
<br/>
Witchy
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#8</link>
<pubDate>Wed, 12 Oct 2016 18:43:27 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#8</guid>
<category>DisplayFusion</category>
<description><![CDATA[We're seeing similar issues with the GetMainWindowByAppID() function here as well. We've added it to our list to fix up
Thanks!]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
We're seeing similar issues with the GetMainWindowByAppID() function here as well. We've added it to our list to fix up <img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/face-smile.light.svg" alt=":)" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:16px;height:16px;" HelpButtonData=":)" HelpButtonDataAlign="BelowMiddle" /><br/>
<br/>
Thanks!
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#7</link>
<pubDate>Wed, 12 Oct 2016 14:32:54 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#7</guid>
<category>DisplayFusion</category>
<description><![CDATA[...and I'm now in a world of firefox bugs. Essentially I can't do what I want to do using firefox, the profiles, -new-instance and other CLI options don't work as documented and in the case of -new-instance are marked as WONTFIX. Which is nice.
I'll just have to loop through the window text inst...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
...and I'm now in a world of firefox bugs. Essentially I can't do what I want to do using firefox, the profiles, -new-instance and other CLI options don't work as documented and in the case of -new-instance are marked as WONTFIX. Which is nice.<br/>
<br/>
I'll just have to loop through the window text instead and fire off the ones that aren't there.<br/>
<br/>
Cheers!
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#6</link>
<pubDate>Wed, 12 Oct 2016 14:00:12 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#6</guid>
<category>DisplayFusion</category>
<description><![CDATA[Hi Collin,
There must be something with the way my machine launches firefox. Your script assumes an instance is already running otherwise it doesn't execute but maybe that's just because there's other things happening outside the snippet you've sent?
This code works for 7-zip and puts the windo...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hi Collin,<br/>
<br/>
There must be something with the way my machine launches firefox. Your script assumes an instance is already running otherwise it doesn't execute but maybe that's just because there's other things happening outside the snippet you've sent?<br/>
<br/>
This code works for 7-zip and puts the window on monitor 2:<br/>
<br/>
        <div class="col-md-12 BoxWrap"><div class="Box table-responsive"><a name="code" style="width:0; height:0;"></a><h2 class="TableTitle" style="border:0"><div class="TableTitleText">Code</div><div class="TitleButtons"><div class="TableTitleButton"><a href="#" onclick="return false;" data-clipboard-target="#code019de4e3fdef77f2bb8d588ffa424635" class="ClipboardCopyControl"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019de4e3fdef77f2bb8d588ffa424635Js'); return false;"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Select All</span></a></div></div></h2><div class="TableTitleContent table-responsive"><div class="AceEditorWrapper" style="border-top:solid 1px var(--color-default-border);padding:0"><pre id="code019de4e3fdef77f2bb8d588ffa424635Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">uint cmd = BFS.Application.Start("C:\\Program Files (x86)\\7-zip\\7zFM.exe", "");
        for (int i = 0; (i &lt; 50) && (!BFS.Application.IsAppRunningByAppID(cmd)); i++)
            BFS.General.Sleep(100);
        IntPtr mainWindow = BFS.Application.GetMainWindowByAppID(cmd);
        //if we failed to get the windows, exit the function
        if (mainWindow == IntPtr.Zero)
            return;
        
        uint monitormonitorID = BFS.Monitor.GetMonitorIDByWindow(mainWindow);
        bool bar = BFS.Window.MoveToMonitor(2, mainWindow);</pre><textarea id="code019de4e3fdef77f2bb8d588ffa424635" name="code019de4e3fdef77f2bb8d588ffa424635" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
but if I change the executable for firefox it fails. Just looking at why....<br/>
<br/>
Cheers!
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#5</link>
<pubDate>Tue, 11 Oct 2016 18:36:42 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#5</guid>
<category>DisplayFusion</category>
<description><![CDATA[If you try the code it will work.  I literally grabbed those first lines from a working function that starts multiple copies of a couple programs, so it will actually handle that as well.
I am guessing your issue actually lies in your pause loop, anyway it looks similar to your code but if you t...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
If you try the code it will work.  I literally grabbed those first lines from a working function that starts multiple copies of a couple programs, so it will actually handle that as well.<br/>
<br/>
I am guessing your issue actually lies in your pause loop, anyway it looks similar to your code but if you test it you will find it does have different results - if you get some time please do try those lines of code in a new function and I think you'll find they work I have been using them for several major revisions now pretty much since external scripted functions were added I believe it was back in v7 where you should still see some of the originally scripted functions in the library under my name.<br/>
<br/>
Thanks!<br/>
<br/>
Collin
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#4</link>
<pubDate>Tue, 11 Oct 2016 15:25:37 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#4</guid>
<category>DisplayFusion</category>
<description><![CDATA[Hi Colin,
Thanks for the quick response! That script assumes FF is already running (GetAppIDByFile) so moves my original FF window (which it CAN get the appID for) to monitor 2 and starts the new instance on monitor 1.
If I change it to be (for example) the arduino IDE I get the same issue - if...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hi Colin,<br/>
<br/>
Thanks for the quick response! That script assumes FF is already running (GetAppIDByFile) so moves my original FF window (which it CAN get the appID for) to monitor 2 and starts the new instance on monitor 1.<br/>
<br/>
If I change it to be (for example) the arduino IDE I get the same issue - if there's nothing of that name running then GetMonitorIDByWindow returns zero after starting the app.<br/>
<br/>
Cheers!
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#3</link>
<pubDate>Tue, 11 Oct 2016 15:01:03 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#3</guid>
<category>DisplayFusion</category>
<description><![CDATA[Have you tried this? (works in my published functions using it):
uint firefox = BFS.Application.GetAppIDByFile("*firefox.exe");
cmd = BFS.Application.Start("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "");
for(int i = 0; (i &lt; 50) && (!BFS.Application.IsAppRunningByAppID(firefox)...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Have you tried this? (works in my published functions using it):<br/>
<br/>
uint firefox = BFS.Application.GetAppIDByFile("*firefox.exe");<br/>
cmd = BFS.Application.Start("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "");<br/>
for(int i = 0; (i &lt; 50) && (!BFS.Application.IsAppRunningByAppID(firefox)); i++)<br/>
BFS.General.Sleep(100);<br/>
IntPtr mainWindow = BFS.Application.GetMainWindowByAppID(firefox);<br/>
//if we failed to get the windows, exit the function<br/>
if (mainWindow == IntPtr.Zero)<br/>
return;<br/>
//TODO:  DO STUFF HERE WITH mainWindow<br/>
<br/>
Hope this helps!<br/>
<br/>
Collin
</div>
]]></content:encoded>
</item>
<item>
<title>RE: BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#2</link>
<pubDate>Tue, 11 Oct 2016 14:49:27 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa#2</guid>
<category>DisplayFusion</category>
<description><![CDATA[*Bump*
Is nobody else using this function?]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
*Bump*<br/>
<br/>
Is nobody else using this function?
</div>
]]></content:encoded>
</item>
<item>
<title>BFS.Application.GetMainWindowByAppID() not working?</title>
<link>https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa</link>
<pubDate>Tue, 04 Oct 2016 15:04:19 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/bfsapplicationgetmainwindowbyappid-not-working/?ID=20936865-2235-4aa9-992a-ed84a4b959fa</guid>
<category>DisplayFusion</category>
<description><![CDATA[Hi,
I'm testing GetMainWindowByAppID() on DF8.0 with the following code:
Code
Copy
Select All
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
public static class DisplayFusionFunction
{
public static void Run()
{
uint appID = BFS.Application.Sta...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hi,<br/>
<br/>
I'm testing GetMainWindowByAppID() on DF8.0 with the following code:<br/>
<br/>
<div class="col-md-12 BoxWrap"><div class="Box table-responsive"><a name="code" style="width:0; height:0;"></a><h2 class="TableTitle" style="border:0"><div class="TableTitleText">Code</div><div class="TitleButtons"><div class="TableTitleButton"><a href="#" onclick="return false;" data-clipboard-target="#code019de4e3fe0d701682ff3bb34ed6f3d1" class="ClipboardCopyControl"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019de4e3fe0d701682ff3bb34ed6f3d1Js'); return false;"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Select All</span></a></div></div></h2><div class="TableTitleContent table-responsive"><div class="AceEditorWrapper" style="border-top:solid 1px var(--color-default-border);padding:0"><pre id="code019de4e3fe0d701682ff3bb34ed6f3d1Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;

public static class DisplayFusionFunction
{
public static void Run()
{

      uint appID = BFS.Application.Start("c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "");
      int count = 0;
while (true)
{
 IntPtr foo = BFS.Application.GetMainWindowByAppID(appID);
 if (foo != IntPtr.Zero)
 break;

BFS.General.ThreadWait(250);
if (++count &gt;= 30000 / 250) // loop for 30 seconds
return;
}

        IntPtr windowHandle = BFS.Application.GetMainWindowByAppID(appID);
        uint monitormonitorID = BFS.Monitor.GetMonitorIDByWindow(windowHandle);
        string output = "";
        output += string.Format("appID 0x{0}: Handle: {1} Monitor: {2} " + Environment.NewLine, appID.ToString(), windowHandle.ToString("x8"), BFS.Monitor.GetMonitorIDByWindow(windowHandle));
        BFS.Dialog.ShowMessageInfoMonospaced(output);
        bool bar = BFS.Window.MoveToMonitor(2, windowHandle);
}
}</pre><textarea id="code019de4e3fe0d701682ff3bb34ed6f3d1" name="code019de4e3fe0d701682ff3bb34ed6f3d1" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
windowHandle is always returned as 0 so the monitor move never happens. I know the window is created OK since the 'list open window information' script shows it and its handle so is there a fault in GetMainWindowByAppID()?<br/>
<br/>
Cheers!
</div>
]]></content:encoded>
</item>
</channel>
</rss>