Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
Dreamer3
16 discussion posts
So I use DisplayFusion to automate a ridiculous amount of things, and I found out I can get it to minimize windows to the system tray that otherwise don't support that functionality. I want to setup a batch file to constantly ping my router to help stabilize my internet connection. I can get DF to launch the batch file, and if I use ctrl+win+T it minimizes the window to the system tray where it is out of sight and out of mind.

I've tried doing a mix between scripted functions and a trigger to launch the batch file and then minimize it to the system tray, but it fails at that last part.

I am using this script to focus cmd

Code

BFS.Window.Focus(BFS.Application.GetMainWindowByFile("*cmd.exe"));


I would have assumed that after the window is focused it is the window that would be affected by the "Minimize Window to System Tray" function being executed directly afterwards, but that doesn't appear to the case. If I manually use ctrl+win+T then it works after the window is focused.

I looked through https://www.displayfusion.com/ScriptedFunctions/Help#bfs_window for a function I could script to specifically minimize cmd to tray but couldn't find one.

A screenshot of the trigger setup I was trying to use is attached. It works exactly how I expected it to until the last step. It's not the most elegant solution, but I want to have the whole process done automatically when I start up my PC and not have a cmd window open on my taskbar the whole time.

Thank you, DisplayFusion is surprisingly powerful for all the weird use cases I use it for. Hope this is possible.
• Attachment: DisplayFusionSettings_2018-04-06_22-45-20.png [32,862 bytes]
DisplayFusionSettings_2018-04-06_22-45-20.png
DisplayFusionSettings_2018-04-06_22-45-20.png
Apr 7, 2018  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Instead of running the Minimize to Tray function as an action in the Trigger, I would just modify your Scripted Function to do it directly, like so:

Code

BFS.DisplayFusion.RunFunctionWithWindowHandle("Minimize Window To System Tray", BFS.Application.GetMainWindowByFile("*cmd.exe"));
Apr 9, 2018  • #2
User Image
Dreamer3
16 discussion posts
Thank you, this works very well.
Apr 10, 2018  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Excellent, glad to hear it!
Apr 11, 2018  • #4
User Image
Paul215
1 discussion post
Hi, I am new to Display Fusion and only have a trial version for now. I am trying to write a scripted function to minimize the current window to the system tray. I added a scripted function that looks like this

Code

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)
    {
        // your code goes here
        BFS.DisplayFusion.RunFunctionWithWindowHandle("Minimize Window To System Tray", BFS.Application.GetMainWindowByFile("Amazon Music.exe"));
    }
}


I put [ctrl]+T as the hot key. I ran the code and it said it ran successfully. I then selected a window and hit [ctrl]+t and the desktop wallpaper DisplayFusion window opens. Can you please help a newbie out here, I'm sure it's something obvious.
Thanks in advance
Mar 16, 2020 (modified Mar 16, 2020)  • #5
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
The GetMainWindowByFile may be looking for a complete path. You can use wildcards to get around this by specifying something like:

BFS.Application.GetMainWindowByFile("*Amazon Music.exe")
Mar 19, 2020  • #6
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)