Click to See Complete Forum and Search --> : How to auto-close inactive Internet Explorer Window


guojinwen
January 23rd, 2003, 09:47 AM
I am writing a program to auto-close Internet Explorer (IE) session if there are no activities for a certain period.

I got 2 problems.

1. Can not close the IE Window.
I am using EnumWindows to loop through all the windows and get the handle to a IE, then I use "DestroyWindow(hWnd);" to close the IE. NOT working. What function should I call to close a running application window ?

2. How to know that an IE session is idle for a certain period already ?

Thanks in advance.

Leslie Guo

Mike Harnad
January 23rd, 2003, 10:38 AM
You say you have the handle to IE. Try posting a WM_QUIT message to it: PostMessage(hwnd, WM_QUIT). If that doesn't work, try PostThreadMessage().

guojinwen
January 24th, 2003, 06:50 AM
tried but not working.

Now I am going to get the process handle and use TerminateProcess()

Anyone know how to know if the process is inactive and for how long ?