Application

Windows and Launching

WaitForWindow and WaitForWindowRegex wait for a window by title and then take it as the window the selectors search, so a workflow can move to a window the launch never knew about. ResizeWindow and MoveWindow act on that window. Maximize, Minimize and Restore act on the application. WithNewInstance says to launch a new copy rather than attaching to one already running, which matters for any program that is always up: explorer.exe is the Windows shell, and Teams, Outlook and a browser are usually running before the workflow starts. Attaching to those hands back whatever window they already had and quietly drops the parameters Open was given.

NOTE

Some programs hand their work to something already running and exit at once. Opening a folder is the usual one: the process that starts takes the folder, passes it to the shell and quits, and the window that appears belongs to the shell. GPAL says so rather than treating it as a failure, and the window has to be found by name with WaitForWindow, which then becomes what the selectors search. A program that is still running but never showed a window is a real timeout and is reported as one.

Examples

GPAL Fluent: High-level fluent C# API

//WithWaitForWindowTimeout sets how long WaitForWindow, WaitForWindowRegex and the file dialog calls will wait. ResizeWindow and MoveWindow act on the window WaitForWindow settled on, so they follow it rather than the window the application started with.

// a program that is always running: launch, do not attach

IApplication explorer = GPAL.Application

.WithNewInstance(true)

.WithParameter(@"C:projects")

.Open(@"C:Windowsexplorer.exe")

.ToGPALObject();


// the launcher exited, so the window is found by name

explorer.WithWaitForWindowTimeout(10);


explorer

.WaitForWindowRegex("projects")

.ResizeWindow(1100, 700)

.MoveWindow(80, 80);

💬 Ask GPAL