<?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: Running macro only if app has focus</title>
<atom:link href="https://www.displayfusion.com/Discussions/RSS/?TopicID=0e02ed88-5529-445c-a809-7e63cbb43e95" rel="self" type="application/rss+xml" />
<link>https://www.displayfusion.com/Discussions/RSS/?TopicID=0e02ed88-5529-445c-a809-7e63cbb43e95</link>
<description>DisplayFusion RSS: Running macro only if app has focus</description>
<lastBuildDate>Mon, 21 Sep 2026 07:40:19 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.displayfusion.com/Discussions/RSS/?TopicID=0e02ed88-5529-445c-a809-7e63cbb43e95</generator>
<item>
<title>RE: Running macro only if app has focus</title>
<link>https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95#4</link>
<pubDate>Wed, 08 May 2019 15:48:57 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95#4</guid>
<category>DisplayFusion</category>
<description><![CDATA[No worries, glad I could help!]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
No worries, glad I could help!
</div>
]]></content:encoded>
</item>
<item>
<title>RE: Running macro only if app has focus</title>
<link>https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95#3</link>
<pubDate>Tue, 07 May 2019 18:56:05 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95#3</guid>
<category>DisplayFusion</category>
<description><![CDATA[Thank you replying. That's much neater than my solution.]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Thank you replying. That's much neater than my solution.
</div>
]]></content:encoded>
</item>
<item>
<title>RE: Running macro only if app has focus</title>
<link>https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95#2</link>
<pubDate>Tue, 07 May 2019 18:54:00 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95#2</guid>
<category>DisplayFusion</category>
<description><![CDATA[Something like this should work:
Code
Copy
Select All
using System;&#xA;using System.Text.RegularExpressions;&#xA;&#xA;public static class ClipboardFusionHelper&#xA;{&#xA;    public static string ProcessText(string text)&#xA;    {&#xA;        if (BFS.Window.GetText(BFS.Window.GetFocusedWindow...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Something like this should work:<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="#code01a0c2e89de576f983c12e5b7dc96534" 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('code01a0c2e89de576f983c12e5b7dc96534Js'); 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="code01a0c2e89de576f983c12e5b7dc96534Js" name="code01a0c2e89de576f983c12e5b7dc96534Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%;min-height:75px">using System;&#xA;using System.Text.RegularExpressions;&#xA;&#xA;public static class ClipboardFusionHelper&#xA;{&#xA;    public static string ProcessText(string text)&#xA;    {&#xA;        if (BFS.Window.GetText(BFS.Window.GetFocusedWindow()).Contains(&quot;Chrome&quot;))&#xA;        {&#xA;            BFS.Dialog.ShowMessageInfo(&quot;blah&quot;);&#xA;            &#xA;            //use the Regex class to replace any matched text with an empty string&#xA;            if (text.Contains(&quot;**&quot;))&#xA;            {&#xA;            text = text.Replace (&quot;**&quot;,&quot;&quot;);&#xA;            text = Regex.Replace (text, @&quot;(.*),.*- (.*),.*(\(.*)&quot;, &quot;$1 vs $2 $3&quot;);&#xA;            }    &#xA;            else&#xA;            {&#xA;                text = Regex.Replace (text, @&quot;\n&quot;, &quot;&quot;);&#xA;                text = Regex.Replace (text, @&quot;.*\[Date &quot;&quot;([1-2][0-9][0-9][0-9]).*\[White &quot;&quot;(.*)&quot;&quot;.*\[Black &quot;&quot;(.*)&quot;&quot;.*\[Result.*&quot;, &quot;**$2 - $3** ($1)&quot;);&#xA;            }&#xA;                &#xA;                BFS.Clipboard.PasteText(text);&#xA;                //get ClipboardFusion to replace the text on the clipboard with the text variable&#xA;            }&#xA;        }&#xA;        return text;&#xA;}</pre><textarea id="code01a0c2e89de576f983c12e5b7dc96534" name="code01a0c2e89de576f983c12e5b7dc96534" style="position:absolute;top:0;left:-999999px;width:1px;height:1px"></textarea></div>
</div></div></div><br/>
<br/>
Note that the "return text;" line needs to either be outside of the if statement, or you have to include it in all of the if/else blocks. (all possible code paths have to return a string). You can also do "return null;" instead if you don't want to put anything back on the clipboard.
</div>
]]></content:encoded>
</item>
<item>
<title>Running macro only if app has focus</title>
<link>https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95</link>
<pubDate>Mon, 06 May 2019 20:14:30 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/running-macro-only-if-app-has-focus/?ID=0e02ed88-5529-445c-a809-7e63cbb43e95</guid>
<category>DisplayFusion</category>
<description><![CDATA[Simple script in ClipboardFusion to replace text.
But I need the macro to only run if Chrome is the focused application.
Had a look at GetMainFileByWindow and other functions but can't get them implemented into the code.
Here's a sample of the current code, and help to add a statement if a win...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Simple script in ClipboardFusion to replace text.<br/>
But I need the macro to only run if Chrome is the focused application.<br/>
Had a look at GetMainFileByWindow and other functions but can't get them implemented into the code.<br/>
Here's a sample of the current code, and help to add a statement if a window (chrome) is the focused app will be appreciated. <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="#code01a0c2e89df8725cbe6cf7b088db574b" 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('code01a0c2e89df8725cbe6cf7b088db574bJs'); 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="code01a0c2e89df8725cbe6cf7b088db574bJs" name="code01a0c2e89df8725cbe6cf7b088db574bJs" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%;min-height:75px">using System;&#xA;using System.Text.RegularExpressions;&#xA;&#xA;public static class ClipboardFusionHelper&#xA;{&#xA;    public static string ProcessText(string text)&#xA;    {&#xA;        //use the Regex class to replace any matched text with an empty string&#xA;    if (text.Contains(&quot;**&quot;))&#xA;    {&#xA;    text = text.Replace (&quot;**&quot;,&quot;&quot;);&#xA;    text = Regex.Replace (text, @&quot;(.*),.*- (.*),.*(\(.*)&quot;, &quot;$1 vs $2 $3&quot;);&#xA;    }    &#xA;    else&#xA;    {&#xA;        text = Regex.Replace (text, @&quot;\n&quot;, &quot;&quot;);&#xA;        text = Regex.Replace (text, @&quot;.*\[Date &quot;&quot;([1-2][0-9][0-9][0-9]).*\[White &quot;&quot;(.*)&quot;&quot;.*\[Black &quot;&quot;(.*)&quot;&quot;.*\[Result.*&quot;, &quot;**$2 - $3** ($1)&quot;);&#xA;    }&#xA;        &#xA;        BFS.Clipboard.PasteText(text);&#xA;        //get ClipboardFusion to replace the text on the clipboard with the text variable&#xA;        return text;&#xA;    }&#xA;}</pre><textarea id="code01a0c2e89df8725cbe6cf7b088db574b" name="code01a0c2e89df8725cbe6cf7b088db574b" style="position:absolute;top:0;left:-999999px;width:1px;height:1px"></textarea></div>
</div></div></div><br/>
<br/>
Just spotted this went into the DisplayFusion section - apologies for that!
</div>
]]></content:encoded>
</item>
</channel>
</rss>