Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

User Image
King_Cronecker
12 discussion posts
I have managed to set up a trigger that opens an application on a certain profile. I would now like to make a trigger that closes it when another profile is launched. Any help would be much appreciated. Cheers.
Apr 22, 2018  • #1
PabloMartinez's profile on WallpaperFusion.com
Change your current trigger by removing the current action from it and adding a new "Run Funciton: Add New Scripted Function" action. Then paste the following code into the window that opens and change the names of your monitor profiles, the path to the application, and the application name in code.

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)
    {
        var monProfile = BFS.DisplayFusion.GetCurrentMonitorProfile();
        
        if (monProfile == "Monitor profile name which to open app")
            // Edit path to your application
            BFS.Application.Start(@"C:\Windows\System32\notepad.exe", "");
            
        if (monProfile == "Monitor profile name which to close app")
            // Edit application name
            BFS.Application.Kill(BFS.Application.GetAppIDByFile("*notepad.exe"));
            
        else
            return;
    }
}
Apr 22, 2018  • #2
User Image
King_Cronecker
12 discussion posts
Thanks so much. I'll try that when I get home :)
Apr 22, 2018  • #3
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)