在用户单击系统任务栏选项卡时拍摄屏幕截图 [英] Taking screenshots when eve the user click on system tray tab

查看:77
本文介绍了在用户单击系统任务栏选项卡时拍摄屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我将开发一个应用程序以截取屏幕截图并在用户单击或打开系统任务栏上的表单时将其保存.


考虑到我有4个任务栏(MS Paint,MS Word,Visual Studio,Firefox)认为所有4个应用程序都在我的系统中运行.当我单击Firefox选项卡时,我的应用程序应该比Firefox窗口短一些.类似于打开的所有其他标签.

我该怎么办,我知道应该使用Win32 DLL,但是我没有使用哪个事件.....

在此先感谢

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

推荐答案

首先,我不确定C#处理shell扩展的能力如何,但是Michael Dunn撰写了一系列关于shell扩展的优秀文章.您应该仔细检查它们,看看是否有什么可以帮助您的.
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.


[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";
        }



每当任务栏更改它时,我都会收到活动的windo事件,称为ForegroundWindow事件.上面的代码为我提供了字符串格式的输出,因此当字符串值发生更改时,意味着将另一个窗口激活,因此我将此方法保持在循环中.我为此添加了一些逻辑.



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.


这篇关于在用户单击系统任务栏选项卡时拍摄屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆