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?

Automatically rotate between windows on a specific monitor

Description
This script will get all of the windows on a specific monitor (set it on line 10) and rotate through them on a specific interval (set it on line 11). To stop the script, right-click its tray icon and choose exit. Note that the tray icon may be in the notification "hidden" area.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Jul 17, 2019
Date Last Modified
Jul 17, 2019

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		// Specify the monitor ID for this script to run on
		// and the sleep time between switching windows (in milliseconds)
		uint monitorID = 2;
		uint sleepTimeMS = 5000;
		
		// Get all of the visible windows on the monitor
		IntPtr[] visibleWindows = BFS.Window.GetVisibleWindowHandlesByMonitor(monitorID);

        // Loop through the windows forever
        while (true)
        {
            foreach (IntPtr window in visibleWindows)
            {
                // Get the currently focused window
                IntPtr currentWindow = BFS.Window.GetFocusedWindow();
            
                // Focus the window on the monitor specified above to bring it to the front
                if (!String.IsNullOrEmpty(BFS.Window.GetText(window)))
                {
                    BFS.Window.Focus(window);
                }
                
                // Return focus to the previously focused window
                BFS.Window.Focus(currentWindow);
                
                // Wait the desired time before continuing to the next window
                BFS.General.ThreadWait(sleepTimeMS);
            }
        }
	}
}