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
cableghost
36 discussion posts
One of the functions in the below code is to 'Save Window Positions'. Is it possible to code in certain app windows to exclude?

Reason...I use an application whereby there's multiple Layouts used and in restoring A DF Windows Profile, the windows get messed up and I want to exclude this app.

Code

using System;
using System.Drawing;
using System.Windows.Forms;

// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Window Location target when run by a Window Location 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)
    {
        //these are all of the functions from the "Window Management" functions list
        //the function are just called by their namess. to find their names, you can copy them
        //from the context menus, or type "BFS.DisplayFusion.RunFunction(" and a window will come up
        //with all of the available functions
        string[] functions = 
        {
            "Save Window Positions",
            "Restore Window Positions From Last Save",
            "Send Window to Back",
            "Toggle Window Always on Top",
            "Toggle Window Transparency",
            "Move Window to Bottom-Left Corner and Size 50%",
            "Move Window to Bottom-Right Corner and Size 50%",
            "Move Window to Top-Left Corner and Size 50%",
            "Move Window to Top-Right Corner and Size 50%",
        };
        
        //create a new ContextMenuStrip to show the items
        using(ContextMenuStrip menu = new ContextMenuStrip())
        {
            //dont show the padding on the left of the menu
            menu.ShowCheckMargin = false;
            menu.ShowImageMargin = false;
            
            //add items to the menu, and use our custom function when a user clicks on the items
            foreach(string function in functions)
            {
                menu.Items.Add(function);
                menu.Items[menu.Items.Count - 1].Click += MenuItem_Click;
            }
            
            //if the menu will show on the screen, show it. otherwise, show it above the mouse
            if(BFS.Monitor.GetMonitorBoundsByMouseCursor().Contains(new Point(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY() + menu.Height)))
                menu.Show(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY());
            else
                menu.Show(new Point(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY()), ToolStripDropDownDirection.AboveRight);
                
            //wait for the menu to close
            while(menu.Visible)
                Application.DoEvents();
        }
    }
    
    //this function will get the text of the item and try to run it as a DisplayFusion function
    private static void MenuItem_Click(object sender, EventArgs e)
    {
        ToolStripItem item = sender as ToolStripItem;
        if (item == null)
            return;

        BFS.DisplayFusion.RunFunction(item.Text);
    }
}
Jul 2, 2019  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Unfortunately there isn't a way to exclude certain windows, no. You could maybe use Window Positions Profiles instead of the Save/Restore Functions, but they may not be as reliable as the functions.

Thanks!
Jul 2, 2019  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)