Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello everyone ,

I am going to develop an application to take screenshots and save it when ever user clicks on the or open the forms on system tray.


Consider that i am having 4 task bar (MS Paint,MS Word,Visual Studio,Firefox) think that all the 4 applications are running in my system. When i click on Firefox tab my application should take snap short of the Firefox window. Similarly to all those other tabs opened.

How can i do it i know Win32 DLL should be used but which event to be used i am not getting .....

Thanks in advance
Posted
Comments
[no name] 20-Jul-12 7:31am    
"How can i do it i know Win32 DLL should be used"... it's called "research"

In the first instance, I am not sure how well C# handles writing shell extensions, but Michael Dunn wrote an excellent series on shell extensions. You should look through them and see if there's anything there that helps you.
 
Share this answer
 
C#
[DllImport("user32.dll")]
        static extern IntPtr GetForegroundWindow();

        [DllImport("user32.dll")]
        static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

        public string GetActiveWindowTitle()
        {
            const int nChars = 256;
            IntPtr handle = IntPtr.Zero;
            StringBuilder Buff = new StringBuilder(nChars);
            handle = GetForegroundWindow();

            if (GetWindowText(handle, Buff, nChars) > 0)
            {
                return Buff.ToString();
            }
            return "some_thing";
        }


I got the active windo event when ever the taskbar changes it is called as ForegroundWindow event. The above code gives me the out in string format ,so I keep this method in a loop when ever the string value changes it means that another window is activated . I added some logic to that an got my work done.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900