<?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: [HELP][SOLVED] Scripted Function - Minimize window if both process file name and class meet criteria</title>
<atom:link href="https://www.displayfusion.com/Discussions/RSS/?TopicID=018bb585-668d-732c-a3df-abd7e2235c12" rel="self" type="application/rss+xml" />
<link>https://www.displayfusion.com/Discussions/RSS/?TopicID=018bb585-668d-732c-a3df-abd7e2235c12</link>
<description>DisplayFusion RSS: [HELP][SOLVED] Scripted Function - Minimize window if both process file name and class meet criteria</description>
<lastBuildDate>Mon, 06 Apr 2026 15:25:57 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.displayfusion.com/Discussions/RSS/?TopicID=018bb585-668d-732c-a3df-abd7e2235c12</generator>
<item>
<title>[HELP][SOLVED] Scripted Function - Minimize window if both process file name and class meet criteria</title>
<link>https://www.displayfusion.com/Discussions/View/helpsolved-scripted-function-minimize-window-if-both-process-file-name-and-class-meet-criteria/?ID=018bb585-668d-732c-a3df-abd7e2235c12</link>
<pubDate>Thu, 09 Nov 2023 19:18:21 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/helpsolved-scripted-function-minimize-window-if-both-process-file-name-and-class-meet-criteria/?ID=018bb585-668d-732c-a3df-abd7e2235c12</guid>
<category>DisplayFusion</category>
<description><![CDATA[EDIT:
Never mind, I got it figured out with the help of ChatGPT! (original post at the bottom)
Here's the final, working Scripted Function:
Code
Copy
Select All
using System;
using System.Drawing;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
EDIT:<br/>
Never mind, I got it figured out with the help of ChatGPT! (original post at the bottom) <br/>
<br/>
Here's the final, working Scripted Function:<br/>
<div id="" 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="#code019d6366884a76889154c03eaf2ce93f" class="ClipboardCopyControl"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019d6366884a76889154c03eaf2ce93fJs'); return false;"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;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="code019d6366884a76889154c03eaf2ce93fJs" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        // Specify target file and class names
        var targetFileName = "Example.exe";
        var targetClassName = "ExampleClass";
        
        // Get main window by file
        IntPtr mainWindowByFile = BFS.Application.GetMainWindowByFile("*" + targetFileName);
        
        // Get window by class
        IntPtr windowByClass = BFS.Window.GetWindowByClass(targetClassName);
        
        // Check if both main window by file and window by class are found
        if (mainWindowByFile.ToString() != "0" && windowByClass.ToString() != "0")
        {
            // Minimize the window
            BFS.Window.Minimize(mainWindowByFile);
        }
    }
}</pre><textarea id="code019d6366884a76889154c03eaf2ce93f" name="code019d6366884a76889154c03eaf2ce93f" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div> —————————————————————————————————————————————————<br/>
—————————————————————————————————————————————————<br/>
<br/>
<del>Can someone please help me create a scripted function that minimizes a window?<br/>
<br/>
I know I could either do this:</del><br/>
<div id="" 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="#code019d6366884e7340811d2762725cd4ed" class="ClipboardCopyControl"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019d6366884e7340811d2762725cd4edJs'); return false;"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;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="code019d6366884e7340811d2762725cd4edJs" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Drawing;

// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Trigger target when run by a Trigger rule
//   - TitleBar Button owner when run by a TitleBar Button
//   - Jump List owner when run from a Taskbar Jump List
//   - Currently focused window if none of these match
public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        BFS.Window.Minimize(BFS.Application.GetMainWindowByFile("*example.exe"));
    }
}</pre><textarea id="code019d6366884e7340811d2762725cd4ed" name="code019d6366884e7340811d2762725cd4ed" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<del>Or this:</del><br/>
<div id="" 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="#code019d6366885077cbadadbdbeb6f86747" class="ClipboardCopyControl"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019d6366885077cbadadbdbeb6f86747Js'); return false;"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;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="code019d6366885077cbadadbdbeb6f86747Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Drawing;

// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Trigger target when run by a Trigger rule
//   - TitleBar Button owner when run by a TitleBar Button
//   - Jump List owner when run from a Taskbar Jump List
//   - Currently focused window if none of these match
public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        BFS.Window.Minimize(BFS.Window.GetWindowByClass("ExampleClass"));
    }
}</pre><textarea id="code019d6366885077cbadadbdbeb6f86747" name="code019d6366885077cbadadbdbeb6f86747" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
<del>But I want the script to minimize the window only if it meets BOTH of the specified criteria. I have no idea how to do even the simplest of scripting operations, so if anyone is willing to, could someone create this scripted function for me?</del>
</div>
]]></content:encoded>
</item>
</channel>
</rss>