January 1, 2005

WinTask - WaitForInputIdle

'
' WaitForInputIdle
'

' Author: Joe Strazzere

'

' This Script will wait until a given window becomes "Idle" - that is:
' waiting for input
' with no input pending
'
' You specify the handle of the window, and a timeout value in milliseconds.
' The script will wait until either the window is idle, or the timeout expires.
'

 

dim hwnd as unsigned
dim pid as unsigned
dim hpid as unsigned

 

'pid=allocate(8)

 

hwnd=GetWindowHandle(Top$(),1)

 

ret=External("user32","GetWindowThreadProcessId",hwnd,pid)
hpid=External("kernel32","OpenProcess",1024,1,pid)
ret=External("user32","WaitForInputIdle",hpid,10000)

 

msgbox(str$(ret))