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?

Kill Zoom if no Zoom windows visible

Description
This script will loop in the background looking for visible or minimized Zoom windows. If it doesn't find any after 30-40 seconds, it will kill all Zoom.exe processes. You can set this to run via a "DisplayFusion Starts" Trigger rule to have it run on system startup. You can exit the script using the DisplayFusion tray icon that has a green arrow overlay.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
May 11, 2023
Date Last Modified
May 11, 2023

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		while (true)
		{
			if (!zoomIsVisible())
			{
				// Wait 30 seconds and check again to make sure it's really not visible
				BFS.General.ThreadWait(30000);
				if (!zoomIsVisible())
				{
					// Kill all Zoom.exe processes
					while (BFS.Application.IsAppRunningByFile("*Zoom.exe"))
					{
						BFS.Application.Kill(BFS.Application.GetAppIDByFile("*Zoom.exe"));
						BFS.General.ThreadWait(1000);
					}
				}
			}
		
			// Wait 10 seconds before starting over
			BFS.General.ThreadWait(10000);	
		}
	}
	public static bool zoomIsVisible()
	{
		// Get all visible and minimized windows
		IntPtr[] visibleWindows = BFS.Window.GetVisibleAndMinimizedWindowHandles();
		
		// Loop through and if any match the Zoom classes, return Zoom as being visible
		foreach (IntPtr window in visibleWindows)
		{
			if (BFS.Window.GetClass(window) == "ZPPTMainFrmWndClassEx" || BFS.Window.GetClass(window) == "ZPContentViewWndClass"  )
			{
				return true;
				break;
			}
		}
		
		// If we got here, there were no visible or minimized Zoom windows
		return false;
	}
}