FUNCTION CloseProgram LPARAMETERS cWindowName Local hMainWnd, hWnd, cWindowTitle #define GW_CHILD 5 #define GW_HWNDNEXT 2 #define CRLF Chr(13)+Chr(10) DECLARE INTEGER GetDesktopWindow IN WIN32API DECLARE INTEGER GetWindow IN WIN32API INTEGER, INTEGER DECLARE INTEGER GetWindowText IN WIN32API INTEGER, STRING, INTEGER DECLARE INTEGER IsWindowVisible IN WIN32API INTEGER DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER DECLARE INTEGER DestroyWindow IN WIN32API INTEGER hMainWnd = GetDesktopWindow() hWnd = GetWindow(hMainWnd, GW_CHILD) Do While hWnd > 0 If IsWindowVisible(hWnd) <> 0 cWindowTitle = Space(100) GetWindowText(hWnd, @cWindowTitle, 100) cWindowTitle = Trim(cWindowTitle) cWindowTitle = Left(cWindowTitle, Len(cWindowTitle)-1) If Upper(cWindowName) $ Upper(cWindowTitle) =DestroyWindow(hwndNext) Exit EndIf EndIf hWnd = GetWindow(hWnd, GW_HWNDNEXT) EndDoENDFUNC
=SetForegroundWindow(hwndNext)
Keyboard '{ALT+F4}'
*****************
This one closes my program only :-) What am I missing here? Thanks for your valuable time and response.
Regards
Vijay