You could try something like this:
Set Text [~~windowTitle] to 'update / checking window title'
Start Loop While : [{WINDOWEXISTS:~~windowTitle}] Equals '1'
End Loop
Set Text [~~targetProcess] to 'process name'
Set decimal [~~appCPU] value to 100,00000
Start Loop While : [~~appCPU] Is Greater Than 5,00000
Inline C# Function: Get CPU usage for process, wait until execution finishes
Begin Decimal Compare : [~~appCPU] Has Not Been Set
End Condition - Exit when condition met
End Loop
Where "Get CPU usage for process" contains:
using System;
using System.Diagnostics;
using System.Threading;
public class VAInline
{
public void main()
{
string targetProcess = VA.GetText("~~targetProcess");
if (!String.IsNullOrEmpty(targetProcess) && Process.GetProcessesByName(targetProcess).Length != 0)
{
PerformanceCounter pc = new PerformanceCounter("Process", "% Processor Time", "VoiceAttack", true);
pc.NextValue();
Thread.Sleep(1000);
decimal appCPU = (decimal)pc.NextValue();
VA.SetDecimal("~~appCPU", appCPU);
}
else
{
VA.WriteToLog("Get CPU usage for process Error: Invalid process name \"" + (targetProcess ?? "Not set") + "\"", "red");
VA.SetDecimal("~~appCPU", null);
}
}
}
The command first checks whether a window exists (you'd want to set "~~windowTitle" to the title of the popup window) and waits until it closes.
Next, the inline function samples the CPU usage of a given process (set "~~targetProcess" to the name of the process you want to monitor) for one second, and if it's over 5% it'll wait until it goes below that (taking a same every second).
5% is just an arbitrary number I picked, you can adjust this.
The percentage is not quite consistent with what task manager shows, but it should work as an indication.
As you'll probably have a multi-core CPU, the percentage may also go over 100%. You could divide by the number of cores, but as you're only using it as an indication of activity that's not really necessary.
You'd have to insert this at the top of any command you may execute while the application is busy.
Otherwise you'd have to modify it to run in the background so it monitors continuously, and provides a way for commands to check the idle state before they execute (you could uses queues with this as well).
None of this is guaranteed to work. Windows doesn't facilitate what you're asking, as GUI applications are generally designed to interact with a human user, so the idea is that you don't provide input when you see the application is busy.