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
Nenn
2 discussion posts
Hello there,

I bought the software yesterday and I am trying to launch multiple different application with one hotkey.

I'd love if this was possible with Window Position Profiles, but have been unable to find any setting that would launch all missing windows / processes and them put them in position. Is this possible? If not, I'd very much love to see it implemented, if that could happen :)

If it's not possible, how can I then achieve opening up multiple applications with preferably one hotkey, maximum two? I have tried making custom functions, but I am unable to bind multiple functions to the same hotkey and as I have seven applications to open, I'd have to have seven different hotkeys :(

Also, I prefer not to use any triggers that fire when a applications, window, process is created, as I also use the applications one by one sometimes.

Thank you very much in advance, I already love the Window Position Profiles for my workflow.

/Nenn
Feb 12, 2019  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
On the Settings > Functions tab, you could add a Scripted Function that launches the applications. Here's an example that opens Notepad++, you can duplicate the BFS.Application.Start line and add other programs as needed.

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        BFS.Application.Start("C:\\Program Files\\Notepad++\\notepad++.exe", "");
    }
}


You could then load your Window Position Profile after running the Scripted Function.

Hope that helps!
Feb 12, 2019  • #2
User Image
Nenn
2 discussion posts
Thank you, that helped a lot.

I ended up doing the following to only start applications that aren't running yet (I don't know if it's the best way, but it seems to work).

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        uint appID1 = BFS.Application.GetAppIDByFile("*notepad++.exe");

        while (true)
                {
                    windowHandle = BFS.Application.GetMainWindowByAppID(appID1);
                    if (windowHandle != IntPtr.Zero)
                        break;

                    else
                        BFS.Application.Start("C:\\Program Files\\Notepad++\\notepad++.exe", "");
                        break;
                }
    }
}
Feb 13, 2019  • #3
User Image
KShaikh
2 discussion posts
Thanks for posting this, Nenn- your solution is exactly what I have been looking for.

Could you suggest how to modify this function to check if the application is running by using the window title instead of the file name?

I tried changing BFS.Application.GetAppIDByFile("*notepad++.exe");
to BFS.Application.GetAppIDByWindow("*windowname"); but that returns the following error: Argument 1: cannot convert from 'string' to 'System.IntPtr'


Mods, or anyone else have any idea how best to go about this?
Sep 25, 2020 (modified Sep 25, 2020)  • #4
Keith Lammers (BFS)'s profile on WallpaperFusion.com
That function requires a window handle, so you'd need to do it like this:

Code

BFS.Application.GetAppIDByWindow(BFS.Window.GetWindowByText("*windowtitle*"))
Sep 29, 2020 (modified Sep 29, 2020)  • #5
User Image
KShaikh
2 discussion posts
Thank you, that worked perfectly.

I'm trying to do what OP mentioned in his original post, perhaps you could help with next steps.

What I'd like to do is:
1. When hotkey is pressed, check if window is open
2. If not, open window(s)
3. Apply Windows Position Profile

Would appreciate any help!
Oct 9, 2020  • #6
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Something like this should get the job done!

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        // Set the Window Position Profile name, window title, application path, and arguments here
        string windowPositionProfile = "profile name";
        string windowTitle = "*Notepad*";
        string appPath = @"C:\Windows\system32\notepad.exe";
        string appArgs = "";
        
        // Try to get the window
        IntPtr window = BFS.Window.GetWindowByText(windowTitle);
        
        // If the handle is null, launch it and apply the Window Position Profile
        if (window == IntPtr.Zero)
        {
            BFS.Application.Start(appPath, appArgs);
            BFS.DisplayFusion.LoadWindowPositionProfile(windowPositionProfile);
        }
        // Otherwise, give it focus
        else
        {
            BFS.Window.Focus(window);
        }        
    }
}
Oct 9, 2020  • #7
User Image
tekstyle
1 discussion post
what is the script if after pressing a set of hotkeys combo or from a created shortcut, I want display fusion to check if application(s) are already openned. launch multiple applications. if already openned, do not open a new session. then apply a preset windows position profile. Thank you.

That last script looks like it might work but i just don't know what to duplicate for multiple apps.
Aug 7, 2024  • #8
Keith Lammers (BFS)'s profile on WallpaperFusion.com
This should do the trick:

Code

using System;
using System.Drawing;
using System.Collections.Generic;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        // Set the Window Position Profile name, window title, application path, and arguments here
        string windowPositionProfile = "profile name";
        List<(string windowTitle, string appPath, string appArgs)> applications = new() {
            new("*Notepad++",@"C:\Program Files\Notepad++\notepad++.exe",""),
            new ("*LogFusion*",@"C:\Program Files\LogFusion\LogFusion.exe","")
        };
        
        foreach (var application in applications)
        {
            string windowTitle = application.windowTitle;
            string appPath = application.appPath;
            string appArgs = application.appArgs;
            
            // Try to get the window
            IntPtr window = BFS.Window.GetWindowByText(windowTitle);
            
            // If the handle is null, launch it and apply the Window Position Profile
            if (window == IntPtr.Zero)
            {
                BFS.Application.Start(appPath, appArgs);
                BFS.DisplayFusion.LoadWindowPositionProfile(windowPositionProfile);
            }
            // Otherwise, give it focus
            else
            {
                BFS.Window.Focus(window);
            }        
        }
    }
}
Aug 14, 2024  • #9
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(2)  Login to Vote(-)