Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
Ronald Luce
1 discussion post
I'm new to Voicebot. I am wanting to create some macros for work productivity.
I have no experience with C code or VBS.
Is it possible to create a delay until a window becomes active?
For example if I start a program and there is a delay as the program loads, can I create a delay in my macro sequence that will wait to proceed to the next macro until the program has loaded and the window for that program is active?
Thanks!
Dec 24, 2018  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
If you use the script to launch the application, you can check to see if it's opened yet and wait longer if it hasn't. Here's some sample code that does that with Notepad:

Code

using System;
using System.Drawing;

public static class VoiceBotScript
{
    public static void Run(IntPtr windowHandle)
    {
        // Launch the application
        uint appID = BFS.Application.Start(@"C:\Windows\Notepad.exe");
        
        // Wait up to 10 seconds for it to finish launching
        for (int i = 0; i < 10; i++)
        {
            // If the window doesn't exist, wait 1 second and try again
            if (BFS.Application.GetMainWindowByAppID(appID) == null)
                BFS.General.ThreadWait(1000);
            // Otherwise, break out of the loop
            else
                break;
        }
    }
}


If you don't want to use scripting, you can just manually add a "Delay" action to the Macro and set it to something that you know will be longer than it takes for the application to open.

Hope that helps!
Dec 31, 2018  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)