Processing Ajax...
Save 25% on our desktop apps during our Black Friday/Cyber Monday sale!Save 25% on our desktop apps during our Black Friday/Cyber Monday sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save 25% on our desktop apps during our Black Friday/Cyber Monday sale!

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Open 2 Applications and Switch Between Them Every 15 Seconds

Description
This script will launch 2 applications (set their paths on lines 9 and 10) and toggle between them every 15 seconds.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Mar 12, 2019
Date Last Modified
Mar 12, 2019

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
        // Set the application paths here
		string app1Path = @"C:\Windows\notepad.exe";
		string app2Path = @"C:\Program Files\Notepad++\Notepad++.exe";
		
		// Launches the applications
		uint app1ID = BFS.Application.Start(app1Path);
		uint app2ID = BFS.Application.Start(app2Path);
		
		// Gets their main windows
		IntPtr app1Window = BFS.Application.GetMainWindowByAppID(app1ID);
		IntPtr app2Window = BFS.Application.GetMainWindowByAppID(app2ID);
		
		// Changes focus every 15 seconds
		// To cancel, right-click the tray icon for the script and choose "Stop Script"
		while (true)
		{
            BFS.Window.Focus(app1Window);
            BFS.General.ThreadWait(15000);
            BFS.Window.Focus(app2Window);
            BFS.General.ThreadWait(15000);
		}
	}
}