FUNCTION x_payrun LPARAMETERS p_title,p_thread * p_thread is used to check to see if the window has been closed LOCAL llThread IF EMPTY(p_title) RETURN -1 ENDIF llThread = .F. IF TYPE("p_thread") = "N" llThread = .T. ENDIF #DEFINE GW_HWNDLAST 1 #DEFINE GW_HWNDNEXT 2 #DEFINE GW_CHILD 5 DO decl LOCAL hDesktop, hFirstChild, hLastChild, rc, cWinCap, cWinClass,; nVisible, nLeft, nTop, nRight, nBottom hDesktop = GetDesktopWindow() hFirstChild = GetWindow(hDesktop, GW_CHILD) hLastChild = GetWindow(hFirstChild, GW_HWNDLAST) hCurrent = hFirstChild DO WHILE .T. cWinCap = GetWinText(hCurrent) IF (UPPER(ALLTRIM(p_title))$UPPER(ALLTRIM(cWinCap))) and IsWindowVisible(hCurrent) <> 0 * got the correct window llReturn = hCurrent IF llThread IF hCurrent = p_thread * window is still open keep solus waiting before shutting down RETURN hCurrent ELSE RETURN -1 ENDIF ELSE * if we find it activate it before closing it Declare Integer ShowWindow in Win32API ; Integer hwnd, Integer nCmdShow * Restore it to its last size and position = ShowWindow(hCurrent,9) EXIT ENDIF ENDIF IF hCurrent = hLastChild llReturn = -1 EXIT ENDIF hCurrent = GetWindow(hCurrent, GW_HWNDNEXT) ENDDO RETURN llReturn * * * FUNCTION GetClsName(hWindow) LOCAL nBufsize, cBuffer cBuffer = Repli(Chr(0), 250) nBufsize = GetClassName(hWindow, @cBuffer, Len(cBuffer)) RETURN SUBSTR(cBuffer, 1, nBufsize) * * * FUNCTION GetWinText(hWindow) * returns window title bar text -- Win9*/Me/XP/2000 LOCAL cBuffer, nResult cBuffer = Space(250) nResult = GetWindowText(hWindow, @cBuffer, Len(cBuffer)) RETURN SUBSTR(cBuffer, 1, nResult) * * * FUNCTION buf2dword(lcBuffer) RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ; BitLShift(Asc(SUBSTR(lcBuffer, 2,1)), 8) +; BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +; BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24) * * * PROCEDURE decl DECLARE INTEGER GetDesktopWindow IN user32 DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @lpRect DECLARE INTEGER IsWindowVisible IN user32 INTEGER hWnd DECLARE INTEGER GetWindowText IN user32; INTEGER hwnd, STRING @lpString, INTEGER cch DECLARE INTEGER GetClassName IN user32; INTEGER hWnd, STRING lpClassName, INTEGER nMaxCount DECLARE INTEGER GetLastError IN kernel32 RETURN * * *