Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
Sorrylol
42 discussion posts
Hey there, I was wondering if anyone knew of a way to create a function that basically when executed acts as: if monitor profile 1 = true, then do ‘x’ action, if monitor profile 2 = true, then do ‘y’ action, if monitor profile 3 = true, then do ‘z’ action’. Basically, one function that depending on which monitor profile I am in, executes a certain command. For example, if current monitor profile = ‘1920’ then execute windows position profile entitled ‘1920x’, or if current monitor profile = ‘5760’ then with the same function, execute windows position profile entitled ‘5760’. Also is there any way to run another function, through this? For example, if current monitor profile = ‘1920’, then run “abc” custom function, or if current monitor profile = ‘5760’, then run ‘def’ custom function. Any input regarding this would be much appreciated, just thought of this as a way to cut down on hotkeys, instead of having like 3 or 4 depending on which monitor profile I am currently in, if it were possible to consolidate it all into one function with one hotkey that acts accordingly depending on which profile I am currently in.
Oct 6, 2020  • #1
User Image
Sorrylol
42 discussion posts
or instead of having it based off of current monitor profile, does anyone know of a way to reference the primary display/monitor resolution somehow? so if primary display resolution = "1920x1080" do 'x' function, or if primary display resolution = "1440x1080" do 'y' function
Oct 8, 2020  • #2
Keith Lammers (BFS)'s profile on WallpaperFusion.com
You can do this with a Scripted Function. Here's some sample code to get you started:

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        // Get the current monitor profile
        string currentMonitorProfile = BFS.DisplayFusion.GetCurrentMonitorProfile();
        
        if (currentMonitorProfile == "monitor profile 1")
        {
            BFS.DisplayFusion.LoadWindowPositionProfile("window position profile 1");
            BFS.DisplayFusion.RunFunction("custom function 1");
        }
        else if (currentMonitorProfile == "monitor profile 2")
        {
            BFS.DisplayFusion.LoadWindowPositionProfile("window position profile 2");
            BFS.DisplayFusion.RunFunction("custom function 1");
        }
        else if (currentMonitorProfile == "monitor profile 3")
        {
            BFS.DisplayFusion.LoadWindowPositionProfile("window position profile 3");
            BFS.DisplayFusion.RunFunction("custom function 1");
        }
    }
}


Hope that helps!
Oct 8, 2020 (modified Oct 8, 2020)  • #3
User Image
Sorrylol
42 discussion posts
Hello Keith, thank you for the reply, I just tried the code, and I get an error when trying to specify the current monitor profile, "Cannot implicitly convert type 'string' to 'bool'", any idea on how to fix this possibly? thanks again tremendously.
Oct 8, 2020  • #4
User Image
Sorrylol
42 discussion posts
turns out it needed 2 equal signs like this to work, "(currentMonitorProfile == "1920")".

thank again! works great.
Oct 8, 2020  • #5
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ah yep! I made a rookie mistake! I've updated my post with that change as well. Glad to hear it worked :)
Oct 8, 2020  • #6
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)