Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Focus the Window Under the Mouse Cursor

Description
This script will focus the window that the mouse cursor is currently under.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Sep 4, 2018
Date Last Modified
Sep 4, 2018

Scripted Function (Macro) Code

using System;
using System.Drawing;
using System.Windows.Forms;

public static class DisplayFusionFunction
{
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern IntPtr WindowFromPoint(Point pnt);

	public static void Run(IntPtr windowHandle)
	{        
        IntPtr windowUnderMouse = WindowFromPoint(Cursor.Position);
        BFS.Window.Focus(BFS.Window.GetParentRoot(windowUnderMouse));
	}
}