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
dbaldon
22 discussion posts
I'm trying to link two Chrome browser windows together so that when the first window gets focus, thw second window also becomes visible. The reasoning is this; window #2 is a tab manager that is "docked" and contains a list of all my open tabs. It's quite nice and really fast but the problem with it not becoming visible when window #1 does is really irritating.

I've managed to get it to work rather clumsily a couple of times but approchaes have their own drawbacks. One approach is to use a trigger for window #1 and then run a function that gets window #2, changes the focus to window @ which causes it to come to the foreground, then I set the focus back to windows #1. Only one small problem; it's basically in a loop because of the trigger.

The second approach is pretty close to the same except instead of setting the focus to window #2, I do a hide and then a show of window #2. That stops the loop but now the window "flashes". Any suggestions on how to accomplish this? My code is shown below.

Approach 1:

Code

using System;
using System.Drawing;
using System.Runtime.InteropServices;

public static class DisplayFusionFunction
{
    private enum ShowWindowEnum : uint
    {
        SW_HIDE = 0,
        SW_SHOWNORMAL = 1,
        SW_NORMAL = 1,
        SW_SHOWMINIMIZED = 2,
        SW_SHOWMAXIMIZED = 3,
        SW_MAXIMIZE = 3,
        SW_SHOWNOACTIVATE = 4,
        SW_SHOW = 5,
        SW_MINIMIZE = 6,
        SW_SHOWMINNOACTIVE = 7,
        SW_SHOWNA = 8,
        SW_RESTORE = 9,
        SW_SHOWDEFAULT = 10,
        SW_FORCEMINIMIZE = 11,
        SW_MAX = 11,
    }

    [DllImport("User32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum nCmdShow);
        
    public static void Run(IntPtr windowHandle)
    {
        IntPtr hwnd = BFS.Window.GetWindowByText("Tabman");
        
        if ((ulong)hwnd > 0) 
        {
            if (BFS.Window.IsMinimized(hwnd))
            {
                BFS.Window.Restore(hwnd);
            }
            else // maybe an if goes here?
            {
                // Hide the window
                ShowWindow(hwnd, ShowWindowEnum.SW_HIDE);
                
                // Wait .10 seconds
                BFS.General.ThreadWait(100);
                
                // Show the window
                ShowWindow(hwnd, ShowWindowEnum.SW_SHOW);
            }
        }
    }
}


Approach 2

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        IntPtr hwnd = BFS.Window.GetWindowByText("Tabman");
        
        if ((ulong)hwnd > 0) 
        {
            BFS.Window.Focus(hwnd);            // Tabman window
            BFS.Window.Focus(windowHandle); // The Chrome window that triggered all this.
        }
    }
}
Feb 10, 2020  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
I can't think of a good way to automate that either. I would probably just write a Scripted Function that focuses both windows, assign a key combination to it, and run it manually when you want to switch to Chrome.
Feb 11, 2020  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)