WaitForWindow

Description:

baWaitForWindow waits until a window is in a specified state, with an optional timeout.

Platforms:

Windows and Macintosh

Usage:

Result = baWaitForWindow( WinHandle , State , TimeOut )

Arguments:

Integer, string, integer.
WinHandle is the handle of the window to wait for.
State is the state to wait for. Can be:

"inactive" 

waits until the window is inactive

"active" 

waits until the window is active

"closed" 

waits until the window is closed
TimeOut is the maximum amount of time to wait in ticks. A tick is equal to 1/60th of a second. If TimeOut is 0, the function will wait indefinitely.

Returns:

Integer.
Returns 0 if the window doesn't exist, or the timeout occurs before the window reaches the specified state.
Returns 1 if the window reached the specified state.

Examples:

Director:
OK = baWaitForWindow( baWinHandle() , "active" , 300 ) -- waits for the Director window to become active, for a maximum of 5 seconds

Authorware:
OK := baWaitForWindow( 3248, "closed" , 600 ) -- waits for the window 3248 to be closed, for a maximum of 10 seconds
 

Notes:

The "inactive" option is useful for waiting until the Director/Authorware window is inactive after starting another program. When the Director/Authorware window is no longer active, then the other program has opened and has focus.

For example, here is some code to open a readme file in Authorware, and wait until the user has finished with it.

if baOpenFile( "readme.txt" , "normal" ) > 32 then -- open readme file
   wnd := baNextActiveWindow( 0 ) -- get handle of Notepad window
   baWaitForWindow( baWinHandle() , "active" , 0 ) -- wait till the Authorware window is active i.e. Notepad has been closed or user switched back to Authorware
   if baWindowExists( wnd )
      then baCloseWindow( wnd ) -- close Notepad
   end if
end if
 

See also:

baWaitTillActive
baNextActiveWindow
baActiveWindow