Interview Questions

WinRunner script for Waitbusy

Mercury WinRunner FAQ

(Continued from previous question...)

WinRunner script for Waitbusy

# only need to load once, best in startup script or wherever load( getenv("M_ROOT") & "\\lib\\win32api", 1, 1 );
# returns 1 if app has busy cursor, 0 otherwise public function IsBusy(hwnd) {const HTCODE=33554433;
# 0x2000001 const WM_SETCURSOR=32;

return SendMessageLong(hwnd, WM_SETCURSOR, hwnd, HTCODE);

# wait for app to not be busy, optional timeout public function WaitBusy(hwnd, timeout) {const HTCODE=33554433;

# 0x2000001 const WM_SETCURSOR=32;
if(timeout) timeout *= 4;
if (SendMessageLong(hwnd, WM_SETCURSOR, hwnd, HTCODE) == 0) return E_OK;

# 1/4 second }
return -1;

# timeout error code }

# wait busy, provide window instead of hwnd public function WinWaitBusy(win, timeout){auto hwnd
; win_get_info(win, "handle", hwnd);
return WaitBusy(hwnd, timeout); }

# example of how to use it... set_window(win); WinWaitBusy(win);

(Continued on next question...)

Other Interview Questions