Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Run Function on Delayed Title Match

Description
This script checks the window title for up to 5 seconds and then runs a function if it matches.
Language
C#.net
Minimum Version
Created By
warthurton
Contributors
-
Date Created
Feb 14, 2018
Date Last Modified
Feb 14, 2018

Scripted Function (Macro) Code

using System;
using System.Drawing;

// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Trigger target when run by a Trigger 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

//  See trigger setup at https://www.displayfusion.com/Discussions/View/howto-trigger-private-browsing-window-for-firefox-58/?ID=4b6c0d14-ec2e-4c53-922e-5028b711deb0#2

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
        string matchText = "Private Browsing - Mozilla Firefox (Private Browsing)";  // Exact text to match
        int maxInterval = 10;    // One interval = 0.5 seconds by default

        string myTest = BFS.Window.GetText(windowHandle);
        int Interval = 0;
        
        while (Interval++ <= maxInterval)
        {
            myTest = BFS.Window.GetText(windowHandle);
            if (myTest == matchText)
            {
                BFS.DisplayFusion.RunFunctionWithWindowHandle("Move Window to Center of Monitor and Size to 75%", windowHandle);
	         
                return;
            }
            BFS.General.ThreadWait(500);
        }	
	}
}