Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

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
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(2)  Login to Vote(-)