<?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: Scripted Function: Current Folder in opened Explorer Window</title>
<atom:link href="https://www.displayfusion.com/Discussions/RSS/?TopicID=32474737-ed09-4cb3-9f84-02306760543c" rel="self" type="application/rss+xml" />
<link>https://www.displayfusion.com/Discussions/RSS/?TopicID=32474737-ed09-4cb3-9f84-02306760543c</link>
<description>DisplayFusion RSS: Scripted Function: Current Folder in opened Explorer Window</description>
<lastBuildDate>Mon, 25 May 2026 02:32:16 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.displayfusion.com/Discussions/RSS/?TopicID=32474737-ed09-4cb3-9f84-02306760543c</generator>
<item>
<title>RE: Scripted Function: Current Folder in opened Explorer Window</title>
<link>https://www.displayfusion.com/Discussions/View/scripted-function-current-folder-in-opened-explorer-window/?ID=32474737-ed09-4cb3-9f84-02306760543c#2</link>
<pubDate>Mon, 09 Aug 2021 12:38:52 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/scripted-function-current-folder-in-opened-explorer-window/?ID=32474737-ed09-4cb3-9f84-02306760543c#2</guid>
<category>DisplayFusion</category>
<description><![CDATA[I found way to do it. If anybody is interested:
Code
Copy
Select All
using System;
using System.Threading.Tasks;
using System.Net;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
ExplorerWindows.InitExplorerHandler();
BFS.Dialog.ShowMessageInf...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
I found way to do it. If anybody is interested:<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="#code019e5cf9d0f374efb7490271602172d0" 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('code019e5cf9d0f374efb7490271602172d0Js'); 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="code019e5cf9d0f374efb7490271602172d0Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Threading.Tasks;
using System.Net;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        ExplorerWindows.InitExplorerHandler();
        BFS.Dialog.ShowMessageInfo(ExplorerWindows.GetPath(windowHandle));
      }
}

// The following code is adapted from this solution:
// https://stackoverflow.com/questions/36886355/retrieve-the-full-path-of-an-explorer-window-through-a-handle-in-c-sharp
public static class ExplorerWindows
{
    static Guid CLSID_ShellApplication = new Guid("13709620-C279-11CE-A49E-444553540000");
    static Type shellApplicationType = Type.GetTypeFromCLSID(CLSID_ShellApplication, true);
    static object shellApplication = null;
    static object windows = null;
    static Type windowsType = null;
    static object count = null;
    
    public static void InitExplorerHandler()
    {
        shellApplication = Activator.CreateInstance(shellApplicationType);
        windows = shellApplicationType.InvokeMember("Windows", System.Reflection.BindingFlags.InvokeMethod, null, shellApplication, new object[] { });        
        windowsType = windows.GetType();
        count = windowsType.InvokeMember("Count", System.Reflection.BindingFlags.GetProperty, null, windows, null);
    }
    
    public static string GetPath(IntPtr windowHandle)
    {
        string currDirectory = "";
        Parallel.For(0, (int)count, i =&gt;
        {
            try
            {
                object item = windowsType.InvokeMember("Item", System.Reflection.BindingFlags.InvokeMethod, null, windows, new object[] { i });
                Type itemType = item.GetType();
                string itemName = (string)itemType.InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, item, null);
                if (itemName == "Windows Explorer" || itemName == "File Explorer" || itemName == "Explorer")
                {
                    string itemHandle = itemType.InvokeMember("HWND", System.Reflection.BindingFlags.GetProperty, null, item, null).ToString();
                    if (itemHandle == windowHandle.ToString())
                    {
                        currDirectory = (string)itemType.InvokeMember("LocationURL", System.Reflection.BindingFlags.GetProperty, null, item, null);
                    }
                }
            }
            catch (Exception e)
            {

            }
        });
        
        return WebUtility.HtmlDecode(currDirectory);
    }
}</pre><textarea id="code019e5cf9d0f374efb7490271602172d0" name="code019e5cf9d0f374efb7490271602172d0" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div>
</div>
]]></content:encoded>
</item>
<item>
<title>Scripted Function: Current Folder in opened Explorer Window</title>
<link>https://www.displayfusion.com/Discussions/View/scripted-function-current-folder-in-opened-explorer-window/?ID=32474737-ed09-4cb3-9f84-02306760543c</link>
<pubDate>Thu, 05 Aug 2021 11:06:54 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/scripted-function-current-folder-in-opened-explorer-window/?ID=32474737-ed09-4cb3-9f84-02306760543c</guid>
<category>DisplayFusion</category>
<description><![CDATA[Hello,
I want to write a scripted Function which does some stuff whenever I open a link to a folder. I set a trigger to run that function whenever a windows is created with Process Filename 'C:\Windows\explorer.exe' and Window Class "CabinetWClass". So far, so good.
But now I want to know the p...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hello,<br/>
<br/>
I want to write a scripted Function which does some stuff whenever I open a link to a folder. I set a trigger to run that function whenever a windows is created with Process Filename 'C:\Windows\explorer.exe' and Window Class "CabinetWClass". So far, so good.<br/>
<br/>
But now I want to know the path to the folder which is shown in that window. One solution would be:<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="#code019e5cf9d1027245aed5c30dd2849b31" 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('code019e5cf9d1027245aed5c30dd2849b31Js'); 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="code019e5cf9d1027245aed5c30dd2849b31Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        if (BFS.Input.IsKeyDown("16")) // Run only, if the Shift key is pressed during start of this function
        {
                BFS.Dialog.ShowMessageInfo(BFS.Window.GetText(windowHandle));
        }
    }
}</pre><textarea id="code019e5cf9d1027245aed5c30dd2849b31" name="code019e5cf9d1027245aed5c30dd2849b31" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
But that only works as intended, if I activate the option 'Show complete path in the title bar' in Windows.<br/>
If that option is not activated, I only get the name of the folder, not the complete path.<br/>
Is there another way to do this?<br/>
<br/>
Thanks,<br/>
Christian
</div>
]]></content:encoded>
</item>
</channel>
</rss>